How do I select a class element based on its id in jQuery?
Posted
by Michael
on Stack Overflow
See other posts from Stack Overflow
or by Michael
Published on 2010-06-15T15:43:48Z
Indexed on
2010/06/15
15:52 UTC
Read the original article
Hit count: 121
I have multiple dynamically generated buttons with a class name of ".button". Each of these are given an unknown ID value used to uniquely identify them. In jQuery I must select one and alert the values.
<div class="button" id="3"></div>
The ID value is dynamically generated, therefore I do not know it. I'm new to jQuery but am basically looking for something like this:
$(".button").attr("id").val();
How do I target one button when there are many? Thanks!
© Stack Overflow or respective owner