Don’t use jQuery.size() to count number of elements
//Code Starts $(document).ready(function(){ var divCount = $("div").size(); alert(divCount); }?);? //Code Ends
But it is not preferred to use the size() method as jQuery provide .length property and which does the same thing. But the .length property is preferred because it does not have the overhead of a function call. So the best way is,
//Code Starts $(document).ready(function(){ var divCount = $("div").length; alert(divCount); }?);? //Code Ends
Also read "jQuery Performance tips & tricks"
Feel free to contact me for any help related to jQuery, I will gladly help you.