セレクターその22(jQueryの独自フィルター headerフィルター/containsフィルター/hasフィルター/parentフィルター)
とりあえず競合が発生しないように全部いれたぜ。
header :h1〜h6要素のこと。独自フィルターにするほど使うのか?
contains:特定の文字列が含まれている要素。
has :特定の「要素」が含まれている要素。
parent :子要素やテキストを含む要素を指定可能。IsParent?みたいなニュアンスかな。
<html> <head> <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript">google.load("jquery", "1.3.2");</script> <script type="text/javascript"> $(function() { $(":header").css("color","red"); $("li:contains('つでぱ')").css("color","blue"); $("li:has(strong)").css("color","green"); $("div ul li:parent").css("color","yellow"); }) </script> </head> <body> <h1>h1タグですよ</h1> <p>テキストテキストテキストテキストテキスト</p> <h6>h6タグですよ</h6> <ul> <li><strong>ぱんぱか</strong>ぱんつ</li> <li>ぱんぱかぱんつ</li> <li>ぱんぱかぱんつ</li> <li>ぱんぱかぱんつでぱんぱかぱん</li> </ul> <div> <ul> <li>ぱんぱかぱんつ</li> <li></li> <li>ぱんぱかぱんつ</li> </ul> </div> </body> </html>
よ〜し、これでセレクター終わり!