kri*_*tya 5 jquery jquery-selectors
我有这个HTML
<tr>
<td>
Main Alliase/Current Alliase:
</td>
<td><input type="text" id="maina" class="countchars" max="30"/><br />
<span class="showchars"></span>
</td>
<td><span id="handle-1" class="selector" title="The Main Alliase with which people know you OR the alliase with which u play most <br /> <b>You'r App would be also named after this only</b>" header="Main Alliase/Current Alliase">?</span></td>
<td><div id="error-1" class="errors"></div></td>
</tr>
Run Code Online (Sandbox Code Playgroud)
而这个js:
$('#maina').focus(function() {
$(this).closest("tr").find(".selector").qtip('toggle', true);
$(this).nextAll(".errors:first").html("Bla");
$(this).siblings(".showchars").show();
});
Run Code Online (Sandbox Code Playgroud)
但是,当我专注于maina它时,它会做其他2件事,但不会改变errors类的html .
为什么这样 ?我做错了什么?请帮帮我谢谢
我认为你应该这样做:
$(this).closest('tr').find(".errors:first").html("Bla");
Run Code Online (Sandbox Code Playgroud)
这是因为 nextAll() 寻找兄弟姐妹 ( Get all following siblings of each element in the set of matched elements, optionally filtered by a selector),而 maina 的唯一兄弟姐妹是 span
| 归档时间: |
|
| 查看次数: |
4305 次 |
| 最近记录: |