Is there a way to store additional information in the HTML tag?
3 answers
HTML5 introduced an attribute data-
just for this. So if you wanted to keep the button number you would name it data-callNum
or something similar.
You can read it here: http://www.w3schools.com/tags/att_global_data.asp
As a warning with JS, you cannot just use normal .
to access the element due to -
, which will be interpreted as a minus operation. So instead button.data-attr
you need to do button.getAttribute('data-attr')
.
0
source to share