+ 9
HTML Elements have Variables?
Attributes in html has weird behaviours...but why can they be used as variables...and why has no one realised this before? https://code.sololearn.com/WUI6X1O8zCbG/?ref=app Is there a downside to using made up attributes as variables? I know one such may be confusing real attributes such as style, but anything else?
5 Respuestas
+ 12
It's common to use attributes as variables. Usually starts with data- and used along with javascript
https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes
+ 4
Data attributes are commonly use on event trigger on class elements.
We should use the format data-<name> which is reserved for data attribute, in order to avoid conflict with standard attributes.
https://code.sololearn.com/Wft4xKwN2waD/?ref=app
+ 2
Toni Isotalo woah. I found out randomly today that it was a possibility.
+ 2
But we don't necessarily need to use data though 😉
0
No html elements does not have variables