I quite often do this:
<input type="text" id="whatever" quantity="2" price="15" />
which causes VS2010 to issue the above warning — I can live with the warnings because the inherent value in being able to hang data on form fields (which allows me later to pick them up for use in code e.g. $('#whatever').attr('price'), or simply document.getElementById('whatever').price) makes the nuisance warnings worth bearing. However, I was wondering what the canonical approach to this problem is…
anyone?
TIA – ekkis
If you’re using jQuery, you can store those variables in the object itself with
.data():But I suggest splitting up your
<input />into multiple<input />s if you absolutely need to keep the information in the HTML file:But for complete HTML5 awesomeness, just prepend
data-to your attributes: