Mr. Noob Mr. Noob - 5 months ago 8
HTML Question

Storing data into elements

I wonder how can I store data into some html elements like div. I can store it in class name, id name, but how does it work with "data"? If I need to store someode id, name, years etc. And to get all that info by jquery.. Like for id

. Thanks


You can do this similarly like ID by adding data attribute in your DIV tag

<div id="elm" data-id="1" data-name="name" data-years="2016">


And then use jQuery like: