内の要素を選択:jQueryの:既に選択された要素例えば
$("table tr").click(function(event)
{
//Say, here i want get the data of td element where its class name="special"
});
、私は要素を選択することができますどのような方法がありますが、クリックイベント、上記の添付要素の下の要素($(」でテーブルtr "))?
内の要素を選択:jQueryの:既に選択された要素例えば
$("table tr").click(function(event)
{
//Say, here i want get the data of td element where its class name="special"
});
、私は要素を選択することができますどのような方法がありますが、クリックイベント、上記の添付要素の下の要素($(」でテーブルtr "))?
を動作することを考えて
$(this).find(".special").html();
のように、あなたがこれを行うことができます:
$("table tr").click(function(event)
{
$(this).children('td.special').whatEverYouNeed();
});
は、一般的に言えば、あなたはfind()
を使用する必要があります。
$("table tr").click(function(event)
{
$(this).find('td.special').whatEverYouNeed();
});
'$( 'td.special'、this)'を使うこともできます。これはセレクタのスコープをコンテナ 'this'に限定します – Jimbo