2011-08-02 17 views
5

mam ten kod HTMLjQuery .nextAll nie działa?

<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> 

I JS:

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

Ale kiedy skupić na maina to robi inne rzeczy, ale robi 2 zmienia html errors klasie.

Dlaczego tak jest? Co robiłem źle? Proszę mi pomóc Dzięki

Odpowiedz

3

myślę, że należy zrobić:

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

Yhis dlatego nextAll() wygląda dla rodzeństwa (Get all following siblings of each element in the set of matched elements, optionally filtered by a selector), a jedynym rodzeństwem Maina jest rozpiętość

+0

próbowałem tego, ale z niewielkimi zmianami i putted „div” w miejsce „tr” – kritya

+0

Jeśli używasz tr masz pewność, aby uzyskać div z błędem klasa w ten sam wiersz –

+0

Ale dlaczego nie div daje mi taki sam wynik? – kritya

1

jako możesz zobaczyć na this example.nextAll() tylko oddaje Ci rodzeństwo.

Można użyć:

$(this).parents("tr").eq(0).find(".errors:eq(0)").html("Bla");