jQuery: get data attribute
问题 In my html I have a span element: <span class=\"field\" data-fullText=\"This is a span element\">This is a</span> And I want to get the data-fullText attribute. I tried these two ways, but they didn\'t work (the both return undefined ): $(\'.field\').hover(function () { console.log(\'using prop(): \' + $(this).prop(\'data-fullText\')); console.log(\'using data(): \' + $(this).data(\'fullText\')); }); Then I searched and found these questions: How to get the data-id attribute? and jquery can't