Javascript handle 2 data attribute

Posted by user3530661 on Stack Overflow See other posts from Stack Overflow or by user3530661
Published on 2014-06-01T02:37:56Z Indexed on 2014/06/01 3:26 UTC
Read the original article Hit count: 70

Filed under:
|
|

I need to use data attribute in my html like <div id="userlist" data-user="A.A.M"></div> then I need to alert the data-user I used

var userlist = document.getElementById("userlist");

var show = userlist.getAttribute("data-user");
alert(show);

My question is how to handle many data-user in the html like

<div id="userlist" data-user="A.A.M"></div> <div id="userlist2" data-user="A.A.M2"></div> to alert A.A.M and A.A.M2

Thanks in advance and sorry for my bad English.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery