Using an if statement to check if a div is empty

前端 未结 10 1143
忘了有多久
忘了有多久 2020-11-28 03:20

I\'m trying to remove a specific div if a separate div is empty. Here\'s what I\'m using:

$(document).ready(function () {
    if (\'#leftmenu:empty\') {
             


        
10条回答
  •  孤街浪徒
    2020-11-28 03:25

    also you can use this :

    
        if (! $('#leftmenu').children().length > 0 ) {
             // do something : e.x : remove a specific div
        }
    

    I think it'll work for you !

提交回复
热议问题