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.

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".

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!
Tags:
re-use selector name jQuery, jQuery define a selector, how to use jQuery selector, jQuery selection, jQuery selection caching , jQuery selector operation, dynamic text generate in jQuery
Total Read: 794 Topics