문제

In HTML 5 its possible to set arbitrary 'data-' attributes to elements like

<div data-blah="blah">

The jQuery framework has methods to do similar things (.data() etc). My question is do the jQuery methods just manipulate and read these html5 data attributes, or they are referring to different jQuery-type data-attributes?

도움이 되었습니까?

해결책

No, totally different things. jQuery's .data() existed even before HTML5.

See: http://api.jquery.com/data/ for details.

To get HTML5 data- attribute value from html tag, try:

jQuery('selector here').attr('data-blah');
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top