jquery擷取table中的某行全部td的內容方法

來源:互聯網
上載者:User

複製代碼 代碼如下:
<table>
<tr class="PurViewData" id="trid95">
    <td>14</td>
    <td id="95"><a style="color:#0000CC" href="/PurviewManage/AddPurview?id=95">TopParty優惠</a></td>    

    <td>                  
        <select id="Select1"> 
        <option value="-1" selected="selected">請選擇角色</option>   
        <option  value='2'>系統管理員</option><option  value='3'>系統管理員2</option><option  value='6'>系統管理員3</option><option  value='23'>系統管理員4</option><option  value='26'>系統管理員5</option>
        </select>
    </td>       
    <td>
        <select id="Select2">                   
        <option value="-1" selected="selected">請選擇許可權</option>                      
        <option  value='1'>搜尋</option><option  value='2'>訪問</option><option  value='3'>建立</option><option  value='4'>修改</option>
        </select>
    </td>
    <td>
        <a  style="color:#0000CC" href="#" id="delecte95" onclick="Bind(this,this.id);">添加</a>
        <a  style="color:#0000CC" href="#" onclick="test1(this.id,this);">刪除</a>
    </td>
</tr>
   </table>   

<script>
function Bind(thisObj, thisObjID) {
    alert("Bind");
    var $td = $(thisObj).parents('tr').children('td');

 //    alert($td.eq(0).text()); //第一個td的內容

//    alert($td.eq(1).text());//第二個td的內容
//    alert($td.eq(2).find("select").val());//第三個td的內容的selected的值
//    alert($td.eq(3).find("select").val());

    var resourceBlockID = $td.eq(1).attr("id");//第二個Td的ID的值,attr("id");擷取該對象的Id值
    var roleId = $td.eq(2).find("select").val();
    var operationId = $td.eq(3).find("select").val();
    alert("資源Id" + resourceBlockID);
    alert("角色Id" + roleId);
    alert("操作ID" + operationId);  

var helptime = new Date().getTime();
}
</script>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.