Hello everyone, welcome to my today's post on jQuery selection operation. In my last tutorial we learned about "How to load jQuery framework from Google code?". Today we are learn about "How to use jQuery selector" and it's operations.

jQuery selectors are awesome. They make selecting any element on the page incredibly simple and easier, but internally they have to do a fair amount of work and if you go mad with them you might find things starting to get pretty slow.

If you're selecting the same element time and time again (in a loop for example) then you can just select it once and keep it in memory while you manipulate it to your heart's content. Take the following example where we add items to an unordered list using a loop.

how to selection operation caching in jQuery?

In this tutorial, we are generating some Dynamic text using loop and then append in to a div. After that, we pick this dynamic text and put them in to another div. Our main goal re-use selector name in any place in our code block. You can see in source code we have declare "$('div#my-texts')" for once and assign it in to a vaiable called "mytexts" and in rest of the code we used "mytexts".

 - Source code for selection operation caching in jQuery:

How to selection operation caching in jQuery?

Demo:  http://demos.coolajax.net/jquery/selection/

Downoad Script: http://demos.coolajax.net/jquery/selection/code.zip

Was this information useful? What other tips would you like to read about in the future?  Share your comments, feedback and experiences with us by commenting below!



Like our site? Be a member of Coolajax fan page to get daily posts updates!

recommended-tutorial You May Like This Posts!

» Life saving jQuery Mobile Code Snippets

» How to allow only numeric input using jQuery!

» Improve your portfolio site with 18 jQuery scripts

» TubePlayer A YouTube Player jQuery Plugins

» Create Stylish Download Button Using jQuery

  tuts_view Total Read: 794
blog comments powered by Disqus

Topics

Coolajax Fans

coolajax fan page on Facebook