2011-07-11 7 views
2

これはスクリプトのコードです。第2のセルからコンテンツを取得する必要があります。 テーブルhasntは、IDを得たが、idを持つdiv要素である[チャット]Jqueryは表の第2セルを選択します

私が選択することができます4行目:

var row = $("#chat tr:nth-child(4)");

ではなく、第二の細胞:

var cellContent = $("#chat td:nth-child(4)").html();

私はポストイメージやテーブルタグができないので、これはテーブルとそのコードのイメージへのリンクです。 http://img577.imageshack.us/img577/8871/chattable.png

+0

ここにあなたのjQueryの質問のHTMLでJSfiddleです:http://jsfiddle.net/CrumK/ – kasdega

+1

私は非常にあなたが離れてこれらの質問を分割お勧めします。 – kasdega

+0

あなたはそれらを分割して良かった!あなたのために働く答えを受け入れることを忘れないでください。 – kasdega

答えて

4

jqueryの質問に役立つうわさがあります。 http://jsfiddle.net/CrumK/1/

$(document).ready(function() { 
    // this reads: find the element with ID chat and inside that find every TR element that is the 2nd child of its parent (meaning TABLE). 
    $("#chat tr:nth-child(2)").css("color", "blue"); // select the second row 

    // this reads: find the element with ID chat and inside that find every TD element that is the 2nd child of its parent (meaning TR)  
    $("#chat td:nth-child(2)").css("background", "red"); // select every second TD 

    // select the second TD of the second TR inside the #chat element 
    $("#chat tr:nth-child(2) td:nth-child(2)").css("background", "green"); // select the second row 
}); 
+0

JQueryの質問を解決したKasdegaさん、ありがとうございます。 ** $( "#チャットtd:nth-​​child(5)")。each(function(){alert($(this))。 html());}); ** ここで最も難しいのは、setInterval Hijack – Borntobewild

+0

です。申し訳ありません。それらを分ける1つの理由。 – kasdega

+0

ここにjqueryの回答があるので、私はあなたのグレースモンキーの質問を受け取り、ここから取り除き、別の質問としてそれを求めます。そうすれば、この答えを受け入れて、他の部分について助けを得ることができます。 – kasdega

関連する問題