[英]Get the clicked table row element value
我知道這已經在這里問了。 我引用了此Link 1和Link 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()
,而不是td
的text()
。 還要注意, 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.