var $myDiv = $("div#myDiv");//example 1
$myDiv.val(); //example 1
var myDiv = $("div#myDiv"); //example 2
$(myDiv).val(); //example 2
Is there any difference between example 1 and example 2 above?
Are both same as far as performance is concerned?
Thanks in advance
EDIT: Now I see you’ve edited your code example yet again (for the 2nd or 3rd time) and the code now looks like this:
In this case, the first example is more efficient because you are directly using the jQuery object you have already created. In the second example, you are creating a new jQuery object from the first jQuery object which there is no reason to do. So example 1 is recommended. Example 2 will work, but is a wasteful and unnecessary.