jQuery children()の例
jQueryでは、children()を使用して、一致した要素の子を検索します。これはtravels a single level downのみです。
たとえば、深さ3レベルのdiv要素には、クラス名「child」および「orphan」が含まれます。
A1-1A1-2A1-3A1-4A2-1A2-2A3-1A3-2
1. $(‘.A1’).children()
$('.A1').children().css('background','red');
「A1」のクラス名とすべてのA1「single level child」を含む要素に一致します。
P.S The A2 and A3 child will be ignore.
2. $(‘.A1’).children(‘.child’)
$('.A1').children('.child').css('background','red');
「A1」のクラス名を含む要素を照合し、「child」のクラス名を含む「A1」の子を検索します。 この例では、all the A1 “single level child” except child with a class name of “orphan” will be selectです。