这是我的 HTML:
<div class="action">
<input type="text" id="StudentName" />
<div></div>
<div></div>
<input type="text" id="item1" />
<input type="text" id="item2" />
<a href="#">yahoo</a>
<input type="text" id="item3" />
<a href="#">gmail</a>
<input type="text" id="item4" />
<a href="#">facebook</a>
</div>
我想找到最近的链接 <a></a>
对于我的选择器。我试过这个:
$("#StudentName").closest('a')
什么是正确的方法?
最佳答案
试试这个:
$("#StudentName").siblings('a:first').html('yahooo');
关于javascript - 找到所选元素的最近链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35315957/