使用jQuery获取tr的第二个td [英] Get second td of tr using jquery
本文介绍了使用jQuery获取tr的第二个td的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试获取tr ..的td值,但不幸的是它不起作用..可能出问题了
I'm trying to get td values of tr.. but unfortunately it's not working.. may be there is something wrong
我的html看起来像
<tr class="dname">
<td>abc</td>
<td>value here</td>
</tr>
我的jquery代码是
My jquery code is
jQuery(".dname").find("tr td:eq(1)").val();
这有什么问题?
推荐答案
jQuery find()
方法返回所选元素的后代.您已经选择了具有dname
类的<tr>
,然后尝试查找也是<tr>
的后代.
jQuery find()
method returns the descendants of the selected element. You are already selecting the <tr>
with a class of dname
and then trying to find a descendant which is also a <tr>
.
以下应能工作:
jQuery(".dname").find("td:eq(1)").text();
text()
代替@ freedomn-m指出的val()
text()
instead of val()
as @freedomn-m pointed out
这篇关于使用jQuery获取tr的第二个td的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文