Mr. Noob Mr. Noob - 2 years ago 107
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

Answer Source

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:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download