I have a page with div elements everywhere.
What’s the best way to get the div elements with a custom ID tag.
e.g. <div rIndex="34">john</div>, <div rIndex="45">Chris</div>
I’m using this function to look for div elements with rIndex attribute. And I want to put those div elements into an array so I can do further processing.
$("div").each(function(index){
if($(this).attr("rindex"))
{
results[index] = $(this);
}
});
alert(results[0])
But the alert message is returning me a function definition, not the element.
HTML
JavaScript
I tidied your HTML up a bit, working demo here – http://jsfiddle.net/aerj4/
If you want an array of the divs, you could do this –