|
|
|
|
|
by 411111111111111
1069 days ago
|
|
lets say you have <body>
<div><!-- you want this one -->
ok
<div id="the-child"></div>
</div>
<div><!-- you dont want this one -->
nok
<div id="the-wrong-child"></div>
</div>
</body>
css: div:has( > #the-child)
xpath: //div[@id="the-child"]/..
isnt that kinda the same? I think I'd even consider the css version to be easier to understand at a glance.If you've got full control over the Dom it'd be much better to just set an id attribute on the element in question though, as getElementById is still the best performing option |
|