How would I go about hiding a div and only displaying it if another div existed on a page? I'm guessing jquery or js would be the way to go....
<style type="text/css">
.always-here {
display:none;
}
</style>
<div class="im-here">This div exists on this particular page!</div>
<div class="always-here">This div is always here but has the style
display: none unless a div with the class "im-here" exists.</div>
For your current current html you can do
.always-here {
display:none;
}
.im-here ~ .always-here{
display:block;
}
this will only work if .always-here
and .im-here
are siblings and .im-here
comes before.
http://jsfiddle.net/BKYSV/ - .im-here
present
http://jsfiddle.net/BKYSV/1/ - .im-here
absent
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With