简体   繁体   中英

Hide div A if div B is empty

I would like to hide div A when Div B has no content inside, I have tried multiple strings of code but I think I am completely missing the idea, here is what I have currently tried

if( $('#b').is(':empty') ) {
$('#a').hide;
}

 if( $('#b').text()=='' ) { $('#a').hide(); } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div id ='a'>asdasdasd</div> <div id='b'></div> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM