开发者

JQuery Find Table within a Table and selected Radio button

开发者 https://www.devze.com 2023-04-12 08:42 出处:网络
Table (tbl_outside) has many rows.In each row is another table (class=tbl_Inside) which contains a radio button group (as shown below).I need to find the value for theselected radio for all rows in th

Table (tbl_outside) has many rows. In each row is another table (class=tbl_Inside) which contains a radio button group (as shown below). I need to find the value for the selected radio for all rows in the table.

This is what I have so far, but I can't seem to find the nested table for each row in tbl_outside. Hope you can help.

$("#tbl_outside > tbody > tr ").each(function() {          
          //find tbl_Inside
          $(this).find("td: > table[class=tbl_Inside]").each(function() {                
                var TRID = $(this).attr("id");
                var theValue = $(this).find("input:radio:checked").val();
                alert(theValue);  
          });        


<table id="tbl_outside">
    <thead>
    <tr>
        <td> Location </td>
    </tr>
    </thead>
    <tbody>
        <tr id="1194">
        <td>
            <table class="tbl_Inside" id="93cf9d8ba8" >
            <tbody>
              <tr>
                  <td></td>
                  <td>
                       <input type="radio" value="h" name="93cf9d8ba8"/>
                  </td>
                  <td></td>
              </tr>
              <tr>
                  <td>
                       <input type="radio" value="l" name="93cf9d8ba8"/>
                  </td>
                  <td>
                        <input type="radio" value="c" name="93cf9d8ba8"/>
                  </td>
                  <td>
                        <input type="radio" value="r" name="93cf9d8ba8"/>
                  </td>
              </tr>
              <tr>
                  <td></td>
                  <td>
                  <input type="radio" value="f" name="93cf9d8ba8"/>
                  </td>
                  <td></td>
              </tr>
              </tbody>
              </table>
         </td>
        </tr>
        <tr id="1193">
        <td>
            <table class="tbl_Inside" id="123456" >
            <tbody>
              <tr>
                  <td></td>
                  <td>
                       <input type="r开发者_开发问答adio" value="h" name="123456"/>
                  </td>
                  <td></td>
              </tr>
              <tr>
                  <td>
                       <input type="radio" value="l" name="123456"/>
                  </td>
                  <td>
                        <input type="radio" value="c" name="123456"/>
                  </td>
                  <td>
                        <input type="radio" value="r" name="123456"/>
                  </td>
              </tr>
              <tr>
                  <td></td>
                  <td>
                  <input type="radio" value="f" name="123456"/>
                  </td>
                  <td></td>
              </tr>
              </tbody>
              </table>
         </td>
        </tr>
    </tbody>
    </table>


$('#tbl_outside table.tbl_Inside input:radio:checked').each(function () {
  alert(this.value);
});
0

精彩评论

暂无评论...
验证码 换一张
取 消