jquery 定位input元素的几种方法小结

2020-05-23 06:16:47易采站长站整理


<html>
<table class=”ed”>
<tr>
<td><input type=”text”></input></td>
<td><input type=”text”></input></td>
<td><input type=”button”></input></td>
<td><input type=”text”></input></td>
</tr>
</table>
</html>

需要定位到第三个文本框的时候:

$(“.ed input:text)”).eq(3)
$(“.ed input:text:eq(3)”)
$(“.ed input[type=”text”]”).eq(3)
$(“.ed input[type=”text”]:eq(3)”)

其中.ed中ed是class=”ed”。