簡體   English   中英

獲取單擊的表行元素值

[英]Get the clicked table row element value

我知道這已經在這里問了。 我引用了此Link 1Link 2,但是在jquery mobile中以相同的方式無法獲取該值。 我想獲取列A值如何獲取此值。

這是我嘗試過的小提琴

代碼就像:

onclick="deleteRow(this)"

function deleteRow(r) {
$(r).parent().parent().hide();

var Something = $(r).closest('tr').find('td:eq(1)').text();
alert(Something);
// this one gave the input element as child 
alert($(r).parent().parent().children().children().html);
alert($(r).parent().parent().children().children().text());

}

同時檢查此小提琴1

您要查找的文本實際上是第一個td內的input值,因此您需要獲取該元素的val() ,而不是tdtext() 還要注意, eq()采用從零開始的索引,因此您需要使用0來獲取行的第一個td 嘗試這個:

function deleteRow(r) {
    var $row = $(r).closest('tr').hide();
    var Something = $row.find('td:eq(0) input').val();
    alert(Something);
}

更新的小提琴

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM