Check if parent element contains certain child element using jQuery

前端 未结 5 807
猫巷女王i
猫巷女王i 2020-12-13 09:21
Blah

I want to set $(\'#

5条回答
  •  余生分开走
    2020-12-13 09:56

    I think what you are looking for is the following

    if (jQuery.contains($('#example'), $('#test')) {
        $('#another').hide();
    }
    

    This might work as well, not sure off the top of my head.

    if ($('#test', $('#example')).size() > 0) {
        $('#another').hide();
    }
    

提交回复
热议问题