2

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, hide that h3.

4

2 に答える 2

6
$('h3').each(function(n, e) {
    $(e).next().is('p') || $(e).hide();
});
于 2010-08-26T00:03:05.647 に答える
3
$('h3').filter(function() { return !$(this).next().is('p') }).hide();
于 2010-08-26T00:05:17.710 に答える