BWSnippet

jQuery data property value

jQuery data property value

get data attribute value from an html element use jquery

if you are using any newer version of jQuery, i.e. greater than 1.45 <- or so, you can just get the "data" like "attr".

 

<div data-nifty="someValue">

hi

</div>

 

var niftyValue = $('.someCoolClass').data("nifty");


Here niftyValue would = someValue

Yay

Tags

jQuery data property value