How do I hide a parent div if the child div doesn't contain an tag?

后端 未结 4 1680
梦毁少年i
梦毁少年i 2021-01-27 07:41

I\'m trying to hide a parent div (i.e., #post) if the child div (i.e., .post-title) doesn\'t contain an tag. Any insight in how to accomplish this correct

4条回答
  •  暖寄归人
    2021-01-27 08:30

    Firstly: dont use IDs mulitple times. Every ID should be unique :)

    Secondly: $('.post').not( ':has(".post-title a")' ).addClass('hide')

提交回复
热议问题