2012-01-13 4 views
0

私は、テーブルの兄弟を取得するjqueryコードを知っています。 このテキストをどのように変数に入れることができますか?jQuery各変数ごとに各兄弟ですか?

jQuery("tbody tr").each(function() { 
    jQuery("td:not(:first)",this).click(function() { 
     alert(jQuery(this).siblings().text()); 
    }); 
}); 

<table> 
<thead><td>A</td><td>B</td></thead> 
<tbody> 
<tr><td class="aclass">A</td><td class="bclass">B</td></tr> 
</tbody> 
</table> 

Set siblings as variable: 

var txtA = jQuery(this).find(".aclass").text(); 
var txtA = jQuery(this).find(".aclass").text(); 

答えて

1

あなたは配列内のテキストを追加することができます。

 

var textsArr = new Array(); 
jQuery("tbody tr").each(function() { 
    jQuery("td:not(:first)",this).click(function() { 
     textsArr.push(jQuery(this).siblings().text()); 
    }); 
}); 

 
+0

私は警告(textsArr)を警告したときに、 配列と同じですが、配列は1つだけです 配列( "one array"); 配列( "one"、 "array")にする必要があります。 – kedomonzter

関連する問題