Use jquery to remove a div with no children

后端 未结 6 1192
予麋鹿
予麋鹿 2020-12-14 09:23

How can I use jquery to remove a SPECIFIC div that has no children (at least no children that isn\'t whitespace). E.g.

some cont
6条回答
  •  独厮守ぢ
    2020-12-14 10:00

    Here is if empty with children then you can point at children and then remove a parent, this dont look at whitespaces it just remove if empty

    so like; if li is empty it removes #removeme

    if (!$("#tabs ul li").length) $('#tabs').remove();
    

提交回复
热议问题