第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

單擊按鈕獲取表行的內(nèi)容

單擊按鈕獲取表行的內(nèi)容

慕沐林林 2019-12-09 14:14:32
我需要提取表中每列的詳細(xì)信息。例如,列“名稱(chēng)/編號(hào)”。該表包含多個(gè)地址每行的最后一列都有一個(gè)按鈕,使用戶(hù)可以選擇列出的地址。問(wèn)題:我的代碼僅拾取<td>具有類(lèi)的第一個(gè)nr。我該如何工作?這是jQuery位:$(".use-address").click(function() {    var id = $("#choose-address-table").find(".nr:first").text();    $("#resultas").append(id); // Testing: append the contents of the td to a div});表:<table id="choose-address-table" class="ui-widget ui-widget-content">    <thead>        <tr class="ui-widget-header ">            <th>Name/Nr.</th>            <th>Street</th>            <th>Town</th>            <th>Postcode</th>            <th>Country</th>            <th>Options</th>        </tr>    </thead>    <tbody>        <tr>            <td class="nr"><span>50</span>            </td>            <td>Some Street 1</td>            <td>Leeds</td>            <td>L0 0XX</td>            <td>United Kingdom</td>            <td>                <button type="button" class="use-address" />            </td>        </tr>        <tr>            <td class="nr">49</td>            <td>Some Street 2</td>            <td>Lancaster</td>            <td>L0 0XX</td>            <td>United Kingdom</td>            <td>                <button type="button" class="use-address" />            </td>        </tr>    </tbody></table>
查看完整描述

3 回答

?
慕標(biāo)琳琳

TA貢獻(xiàn)1830條經(jīng)驗(yàn) 獲得超9個(gè)贊

您需要更改代碼以找到與單擊的按鈕相關(guān)的行。嘗試這個(gè):


$(".use-address").click(function() {

    var id = $(this).closest("tr").find(".nr").text();

    $("#resultas").append(id);

});


查看完整回答
反對(duì) 回復(fù) 2019-12-09
?
冉冉說(shuō)

TA貢獻(xiàn)1877條經(jīng)驗(yàn) 獲得超1個(gè)贊

嘗試這個(gè):


$(".use-address").click(function() {

   $(this).closest('tr').find('td').each(function() {

        var textval = $(this).text(); // this will be the text of each <td>

   });

});

這將找到tr當(dāng)前單擊的按鈕中最接近的(在DOM中向上移動(dòng)),然后循環(huán)每個(gè)按鈕td-您可能要使用值創(chuàng)建一個(gè)字符串/數(shù)組。


查看完整回答
反對(duì) 回復(fù) 2019-12-09
  • 3 回答
  • 0 關(guān)注
  • 775 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)