chuanxshi / javascript-patterns

JavaScript Design Patterns
http://shichuan.github.io/javascript-patterns
9.39k stars 1.69k forks source link

jQuery.data() vs. jQuery().data() should be more clear #64

Closed dieseltravis closed 8 years ago

dieseltravis commented 12 years ago

I think it just needs a bit of documentation that elem is a DOM element, not a jQuery object. Also it should be noted that using jQuery.data(domElem, "key") will not pull in the HTML5 data-* attribute data-key="value" like calling jQuery(domElem).data("key") would.

Here's an example showing how they fail: http://jsbin.com/exapef/1/edit