jQuery .data usage

jQuery .data()  usage :
====================

I use .data for storing values instead of accessing DOM elements. I realized and found a better and faster way of it. In fact I have been using $('#myElementID').data(myKey,myValue); for a while now. 

Check out these cases.  

The other way for the same is as -

$.data('#myElementID', key, value );


case 1 : 

$('#myElementID').data(key,value);

It creates a jQuery object and then do the data parsing. It creates an overhead.

case 2 :

$.data('#myElementID', key, value );

This one is faster than first. As it does not go for object creation.


Thanks.
Please comment.




Next Recommended Reading Bind List Data to JQuery Data Table