I’m very new at this, so please forgive me if I’m not explaining this correctly, or not providing the right code (or providing too much).
So near the top of my page I have this code:
<div id="javo-detail-item-header-wrap" class="container-fluid javo-spyscroll lava-spyscroll" style="padding: 0px; z-index: 1;">
And then further down the page:
<div id="post-2355" class="single-item-tab post-2355 property type-property status-publish has-post-thumbnail hentry property_type-ny property_status-sold">
I want to target #javo-detail-item-header-wrap
from the first line of code, but ONLY when .property_status-sold
is also on the page.
From what I understand it’s not possible to target an element via CSS by its descendant, right? I’ve seen mentions online of a similar situation being solved by renaming the first ID with jQuery – is that what needs to be done here?
IS the second element even a descendant of the first if it’s not in the same div?
Without seeing your full code structure, I’d say 99% it’s not possible using plain CSS. Doing it in JavaScript should be quite easy:
To get your element, just call the function
getIt
(and give it a better name) – it will return either the element reference, orundefined
if either the.property_status-sold
is not found or the actual element#javo-detail-item-header-wrap
is missing for some reason.If you really like jQuery that much, here’s the above code (note that it returns a jQuery object, not the element reference – you can use
.get(0)
to the the element reference):A quick-fix for hiding that element:
This is all you need.
Try This :