Car*_*Jr. 16 html jquery jquery-selectors
我仍然是jquery的新手,我有这个代码
<div>
abcsdf
<div> first child</div>
<div> second child</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我想得到第二个孩子,他们使用追加动态填充,我不知道如何得到它.
我想要展示
$('the second element inner html here').dialog() etc..
希望有人可以帮助我.
谢谢
iss*_*eng 35
有很多方法可以做到这一点.我将假设顶级div的id为'top'.这可能是最好的一个:
$('#top > :nth-child(2)').whatever();
Run Code Online (Sandbox Code Playgroud)
要么
$('#top').children(':first-child').next().whatever();
Run Code Online (Sandbox Code Playgroud)
或者如果你知道一个事实,至少有2个孩子
$($('#top').children()[1]).whatever();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
45014 次 |
| 最近记录: |