eye eye - 6 months ago 19
jQuery Question

jQuery - find all IDs in a class

Let's say i have a html table like this:

<tr id="a" class="red"><td>test</td></tr>
<tr id="b" class="red"><td>test</td></tr>
<tr id="c" class="red"><td>test</td></tr>
<tr id="d" class="red"><td>test</td></tr>
<tr id="e" class="green"><td>test</td></tr>
<tr id="f" class="blue"><td>test</td></tr>

How can i loop through/get all ids of class "red" using jQuery?


Use .each()

var idArray = [];
$('.red').each(function () {