日期:2014-05-16  浏览次数:20407 次

~~~~~~~~~jquery获取DIV中的TR和TD值,马上给分~~~~~~~~~~~
<div id="dvABC">
  <table class="l_height_30 gridcontent" width="100%" border="0" cellspacing="0" cellpadding="0">
    <thead>
      <tr>
        <td width="50" class="bg_thead center">序号</td>
        <td class="bg_thead pl_10">内容</td>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td width="50" class="bg_thead center"><input class="radio_box" name="infolist" type="radio" value="8123" ></td>
        <td class="bg_thead pl_10">aaaaa</td>
      </tr>
      <tr class="odd selected">
        <td width="50" class="bg_thead center"><input class="radio_box" name="infolist" type="radio" value="2659" ></td>
        <td class="bg_thead pl_10">bbbbb</td>
      </tr>
      <tr>
        <td width="50" class="bg_thead center"><input class="radio_box" name="infolist" type="radio" value="3472" ></td>
        <td class="bg_thead pl_10">ccccc</td>
      </tr>
    </tbody>
  </table>
</div>
<input class="bt_save mr_20" type="button" value="SAVE" />



1. 如何点击表格中的行使得radiobox被选中?
2. 点击SAVE按钮获取选中行的radio box的值和第2列的值?

------解决方案--------------------

 $("#dvABC tbody tr").click(function () {
        $(this).find(":radio").prop("checked", true);
    });
    $(".bt_save").click(function () {
        var $radio= $("#dvABC input:radio:checked");
        alert($radio.val());
        alert($radio.parent("td").next("td").text());
    });

------解决方案--------------------

<script type='text/javascript'>
$(function(){
$("#dvABC table tr").click(function(e){
$(this).find("td>input[type='radio']").attr('checked','checked');
});
$(".bt_save").click(function(e)