Possible Duplicate:
jquery v1.3.2 find element by attribute
Is it possible to grab a link by its href if it doesn’t have a class or ID?
My question revolves around having an attribute to an element (can't use ID's as I can' be certain that those will be unique) -
for instance, I have this:
<a href="someurl.com">Link</a>
but I can dynamically inject and could I possibly have a feasible/fast/efficient way of referencing this in the dom (keep in mind, there would be numerous links like this).
<a href="someurl.com" data-access-label="000998">Link</a>
So, I will be reiterating thru a hash and curious if this would be fast/efficient?
data = {
'98789' : 'yeah',
'871637':'cool',
'00198789' : 'sure thing',
'871609':'no way',
'000998':'alright'
}
So, it seems inefficient to me that I would .each thru all the links then find the data-access-label value, and then what? could I possible bind those hrefs or something so that once I run my function - it would look like this
<div>
<a href="someurl.com" data-access-label="000998">Link</a> alright
<span> <a href="someurl.com" data-access-label="871637">Link</a> cool</span>
</div>
At any given time there will be only upwards of 40 items in the data hash, so perhaps I could ".each" thru it, and match the key with the value in those data-access-label ? But my want is perhaps directly accessing that item rather than reiterating thru href's too.