jquery visibility depending on existence of other div
(use display:none)
by Roberto Apasajja
HTML
<div id="one">
one
<div id="two">
two
</div>
</div>
<div id="first">
first
<div id="second">
second
</div>
<div id="secondb">
secondb
</div>
</div>
CSS
#one{
width:200px;height:100px;
background:pink;
}
#two{
width:100px;height:50px;
background:purple
}
#first{
width:200px;height:140px;
background:green
}
#second{
width:100px;height:50px;
background:red;
display:none;
}
#secondb{
width:100px;height:50px;
background:yellow;
display:none;
}
JavaScript
if($('#two').length > 0) {
$('#second').show()
}
if($('#two').length == 0) {
$('#secondb').show()
}