私は次のようなフォームを持っています:
<ul id="services">
<li class="service"><label><input type="checkbox">A single option</label>
</li>
<li class="service"><label><input type="checkbox">Another single option</label>
<ul>
<li>
<select>
</select>
additional options</li>
</ul>
</li>
<li class="service"><label>
<select>
</select>
A multiple option</label>
<ul>
<li><label><input type="checkbox"> with another option </label>
<select>
</select>
</li>
</ul>
</li>
<li class="service"><label>
<select>
</select>
Another multiple option</label>
<ul>
<li><label><input type="checkbox"> with another option </label>
<select>
</select>
</li>
<li>
<select>
</select>
additional options</li>
</ul>
</li>
そして、私はこれを使用して、「サービス」クラスを持つs<label>
の最初のレベルのsのみを選択しようとしています:<li>
$(".service label:first-child").css("background", "yellow");
しかし、は再帰的であるように見え、ネストされたsの最初の子を選択してい<ul>
ます。
私はここで何が間違っているのですか?「サービス」クラスを持つの<label>
最初のレベルでのみを選択するにはどうすればよいですか?<li>