问题描述
我想在以下 HTML 结构中使用 Jquery 将Yes!Pick me"更改为Picked",我使用了 $('#myDiv>table>tr>td>table>tr').eq(1).text("Picked");
但它不起作用.有人可以对此有所了解吗?谢谢!
仅供参考,第一个表的第一个 td 本身包含另一个表...
<表格><tr><td><表格><tr><td>是的!选我吧!</td><td>不是我..</td></tr><tr><td>不是我..</td></tr></td><td>不是我..</td></tr><tr><td>不是我..</td></tr>
$('#myDiv>table>tr>td>table>tr>td').eq(1).text("Picked");
部分起作用了,我忘了最后的 td 部分.感谢 Rocket 和大家的帮助.
试试这个:
$("#myDiv table table td:first").text("Picked")
I want to change the "Yes! Pick me" into "Picked" with Jquery in the following HTML structure, I used $('#myDiv>table>tr>td>table>tr').eq(1).text("Picked");
But it was not working. Could someone shed some light on this please? Thanks!
FYI, the first td of the the first table itself contains another table...
<div id="myDiv">
<table>
<tr>
<td>
<table>
<tr>
<td>Yes! Pick me!</td>
<td>Not me..</td>
</tr>
<tr>
<td>Not me..</td>
</tr>
</table>
</td>
<td>Not me..</td>
</tr>
<tr>
<td>Not me..</td>
</tr>
</table>
</div>
The section $('#myDiv>table>tr>td>table>tr>td').eq(1).text("Picked");
does the trick, I forgot the last td part. Thanks to Rocket and everyone's help.
Try this:
$("#myDiv table table td:first").text("Picked")
这篇关于如何使用 Jquery 选择第一个 td 元素及其文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!