I have 3 div's drawing content from fields in a database:
<div id="one">{data_one}</div>
<div id="two">{data_t开发者_运维问答wo}</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
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();
}
}
if($('#one').html() == '' && $('#two').html() == '' && $('#three').html() == '') {
$('#anotherDiv').hide();
}
精彩评论