Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery .nextAll not working?

I got this 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>

And this js:

$('#maina').focus(function() {
$(this).closest("tr").find(".selector").qtip('toggle', true);
    $(this).nextAll(".errors:first").html("Bla");
    $(this).siblings(".showchars").show();
});

But the when i focus into the maina it does the other 2 things but doesnt changes the html of errors class.

Why so ? What have i been doing wrong ? Please help me Thanks

like image 646
kritya Avatar asked Oct 11 '22 08:10

kritya


1 Answers

I think you should do:

 $(this).closest('tr').find(".errors:first").html("Bla");

Yhis is because nextAll() looks for siblings (Get all following siblings of each element in the set of matched elements, optionally filtered by a selector), and the only sibling of maina is the span

like image 68
Nicola Peluchetti Avatar answered Oct 14 '22 03:10

Nicola Peluchetti