「jQuery入門」find()、children()とparents()の使い方

1.find()で子孫要素を取得
$(“table.demoTbl”).find(“td”).css(“background-color”, “red”);

2.children()で子要素を取得
$(“table.demoTbl”).children(“tbody”).children(“tr”).children(“td”).css(“background-color”, “blue”);

3.自身の親のtdを取得
$(this).parents(“td”);

Comments are closed.