[英]Get the clicked table row element value
I know this already asked here. 我知道这已经在这里问了。 I referred this Link 1 , Link 2 but working the same in jquery mobile not able to get the value.
我引用了此Link 1和Link 2,但是在jquery mobile中以相同的方式无法获取该值。 I want to get column A value how to get this one.
我想获取列A值如何获取此值。
Here is the Fiddle what i tried 这是我尝试过的小提琴
Code is like: 代码就像:
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());
} }
The text you're looking for is actually the value of the input
within the first td
, so you need to get the val()
of that element, not the text()
of the td
. 您要查找的文本实际上是第一个
td
内的input
值,因此您需要获取该元素的val()
,而不是td
的text()
。 Also note that eq()
takes the index which is zero-based, so you need to use 0
to get the first td
of the row. 还要注意,
eq()
采用从零开始的索引,因此您需要使用0
来获取行的第一个td
。 Try this: 尝试这个:
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.