views:

33

answers:

1

I have a table that looks somethings like this:

<table>
  <tr class="row even">
    <td><input type="checkbox" /></td>
    <td class="name">foo</td>
    <td class="metric">22</td>
  </tr>

  ...etc

What I want to do is get an array of all td.metric only in rows that have the checkbox checked. This didn't work out as expected:

var ticks = $.map($("tr td input:checked td.metric"), function(v,i){ return ... }); 
+2  A: 

Use the :has selector:

$('tr:has(input:checked) > .metric');

http://jsfiddle.net/RqjFX/

Andy E
Now that's what I call sexy :) (I know I know, I'm sad)
thisMayhem
perfect! thank you
Russ Bradberry