Hi All,
Is it possible to find how many instances of the same class(.rtmenu) are visible? Then target each individual?
Much Appreciated, Thanks
Hi All,
Is it possible to find how many instances of the same class(.rtmenu) are visible? Then target each individual?
Much Appreciated, Thanks
$('.rtmenu:visible').each(function(){
//$(this) is the referenz to the DOM-Element.
});
what floyddotnet said.
and $('.rtmenu:visible').length if you still want to know how many of them there are.
Edit in response to question in the comments -
there are a bunch of ways to target a specific element, depends on exactly what you mean. You can loop through them all one by one with each (see the other answer). You can access the indexor and element in each using the alternative signature:
$('.rtmenu:visible').each(function(index, elem) { ... });
you can use an index selector directly:
$('.rtmenu:visible').eq(1); // select the 2nd element (index is 0 based)
Or of course you could use a specific Id or multiple class selector if you really only want to find a specific element.
The jQuery documentation is pretty good, poke around in there and you can usually find something that does what you need, with good examples.