jQuery – ユニバーサルセレクタの例
例
-
$( ‘** ‘):ドキュメント内のすべての要素を選択します.
-
$( ‘div> ** ‘):<div>要素の子要素をすべて選択します.
素子。
一般的には、ユニバーサルだけでは意味がありませんでしたが、少なくとも私はユースケースについて考えることはできません。しかし、それは常に新しいカスタムセレクタ式を形成するために他の要素と結合するために使用されます。
jQueryの例
jQuery Universal ** セレクタの使い方を示す簡単な例です。
<html> <head> <title>jQuery universal example</title> <script type="text/javascript" src="jquery-1.3.2.min.js"></script> <style type="text/css"> div{ padding:8px; } </style> </head> <body> <h1>jQuery universal example</h1> <div class="div-class1"> This is div-class1 <div class="div-class2"> This is div-class1 </div> <div class="div-class3"> This is div-class3 </div> </div> <br/><br/> <button>** </button> <button>div > ** </button> <button id="refresh">Refresh</button> <script type="text/javascript"> $("button").click(function () { var str = $(this).text(); $(str).css("border", "1px solid #ff0000"); }); $('#refresh').click(function() { location.reload(); }); </script> </body> </html>