.focusin()方法
点击聚焦: eq(1) /last - child
点击聚焦并传递参数: eq(3) / last / last-child
<div class="left">
<div class="aaron">
点击聚焦:<input type="text" />
<br>
点击聚焦:<input type="text" />
</div>
</div>
<div class="right">
<div class="aaron1">
点击聚焦并传递参数:<input type="text" />
<br>
点击聚焦并传递参数:<input type="text" />
</div>
</div>
总结
1. 用eq(0)-(3)可以分别准确地指定4个input.
2.点击聚焦和点击聚焦并传递参数的2段代码中,如果
用 $("input:last")作为选择器,结果只改变了eq(3)
$("input:last-child")作为选择器,改变eq(1)和eq(3)
$("input:first")作为选择器,结果只改变了eq(0)
$("input:first-child")作为选择器,改变eq(0)和eq(2)
翻了下W3School中的例子:
选择属于其父元素的首个子元素的每个元素,并为其设置样式:
p:first-child{ background-color:yellow;}
这说明,使用first-child的元素需要满足两个条件:
被选取input有父元素,而且input是该父元素的第一个元素
此外p:last-child 等同于 p:nth-last-child(1)。