jquery - If a div inside of a div is empty change the background color of the parent CSS -
i trying check if status_comment_holder
empty , if want change background of comment-container
without having refresh page, @ moment, appending comments status_comment_holder
, removing comment when remove comment, not sure if can css or jquery have marked tags both.
<div class="well well-small comment-container" id="comment-container""> <div class="status_comment_holder" id="image_comment"></div> </div>
i have tried:
if($('#image_comment').is(':empty')){ alert("fhfhf"); $('.well').css('background-color', '#ffffff'); }
with no avail, it's not alerting reason.
check out: how check if html element empty using jquery?
your idea seems fine enough, maybe div has whitespace inside? try like
if($.trim($("selector").html())=='')
or, adriano repetti said in comments:
if($("selector").children().length == 0)
which more cpu-efficient
hope helps!
Comments
Post a Comment