Reputation: 1184
I have 3 div's drawing content from fields in a database:
<div id="one">{data_one}</div>
<div id="two">{data_two}</div>
<div id="three">{data_three}</div>
If none of these three div's have data, can I add some jQuery to hide another div?
Thanks, Jack
Upvotes: 0
Views: 100
Reputation: 744
I have a strong feeling that this would be better handled on the server side, since you would probably like this to work for people who have JavaScript disabled as well.
If it needs to be in jQuery though, you could do something like this:
$(function() {
if($("#one").html() == "" && $("#two").html() == "" && $("#three").html() == "") {
$("#someOtherDiv").hide();
}
}
Upvotes: 2
Reputation: 129792
if($('#one').html() == '' && $('#two').html() == '' && $('#three').html() == '') {
$('#anotherDiv').hide();
}
Upvotes: 1