这是我试过,但它是选择所有a
标记,在其他divs
我怎样才能穿越的深度嵌套的div无类属性
$('div:has(> div > div > a[href*="hello/"])').css("color", "blue");
但这种选择每<a>
。但我需要<a>
的即在深度嵌套<div> <a href="hello/..">
<body>
<div class="headers">
<div>
<a href="welcome/"> welcomes one</a>
<a href="welcome/"> welcomes two</a>
</div>
</div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
</div>
</div>
<div>
<div>
</div>
<div class="columns">
<div>
<div> <a href="hello/one"> once</a></div>
<div> <a href="hello/two"> twice</a></div>
<div> <a href="hello/three"> thrice</a></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
为什么不只是'$ ('.columns a')'或'$('a [href * =“hello /”]')'??? ....或者你只需要最深的'a'元素? – DaniP
*“,但是这会选择每个''”*不,它不会...它会选择包含它们的div。 –
'$('。columns a')'或'$('a [href * =“hello /”]')'它们都选择了所有'a'元素。需要嵌入深度最深的div中最深的元素。这些:'