I have a div with id #wrapper and all the elements inside it. I cache the shell by doing
var $wrapper = $('#wrapper');
Now, when I want to make a selector or link to an element, I do
$wrapper.find('#whatever').click(....
Having done this, I will no longer wrap the jQuery object, so any selector that I will do in the future will be based on $wrapper caching. But on the other hand, when I use find() with a cached shell $, I know that it will look for all the elements inside #wrapper . My questions are better, use a cached variable, and then find the click click event, or just do $('#whatever').click(..
whatever can be either a class or id.
source share