开发者

jQuery: Check for next element, if not hide

开发者 https://www.devze.com 2023-01-14 09:28 出处:网络
I have some H3 elements that sometimes are followed by a P element.I would like to check and see if the next element after the h3 is a p, and if not, hid开发者_运维知识库e that h3.$(\'h3\').each(funct

I have some H3 elements that sometimes are followed by a P element. I would like to check and see if the next element after the h3 is a p, and if not, hid开发者_运维知识库e that h3.


$('h3').each(function(n, e) {
    $(e).next().is('p') || $(e).hide();
});


$('h3').filter(function() { return !$(this).next().is('p') }).hide();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号