2011-08-02 15 views
5

私は、このHTMLjQuery .nextすべて動作していませんか?

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

を持って、これはJS:

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

が、私は、それは他の2つのことを行いますが、doesntのはerrorsクラスのHTMLを変更するmainaに焦点を当てたときに。

なぜですか? 何が間違っていますか? 私 おかげ

答えて

3

を助けてください、私はあなたがやるべきだと思う:

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

nextAllは()兄弟(Get all following siblings of each element in the set of matched elements, optionally filtered by a selector)を探し、MAINAの唯一の兄弟のようにスパン

+0

私はこれを試してみましたが、少しの変化で、私は「TR」の代わりに「DIV」をパット – kritya

+0

あなたがTRを使用している場合は、中クラスのエラーでのdivを取得するのは確実です同じ行 –

+0

しかし、なぜdivが私に同じ結果を与えるのですか? – kritya

1

あるのでYhisがありますあなたはthis exampleの上に見ることができます.nextAll()はあなただけの兄弟を与える。

あなたが使用することができ

$(this).parents("tr").eq(0).find(".errors:eq(0)").html("Bla"); 
関連する問題