I’d like to have some HTML like this:
<div id="div0" someAttr="0" class="shown">Some stuff</div>
<div id="div1" someAttr="1">Some stuff</div>
<div id="div2" someAttr="2">Some stuff</div>
<div id="div3" someAttr="3">Some stuff</div>
And then manipulate it like this:
$('div').click(function()
{
if($(this).someAttr > $('div.shown').someAttr)
doSomething();
});
But I don’t want to write bad markup. Is there an all-purpose attribute I can set?
You could use the jQuery
.data()method, allows you to apply data to an element without having to use attributes in an non-semantic fashion.That said looking back at your question are you looking at generating those values from the back end or using jQuery?
http://api.jquery.com/jQuery.data/