开发者

Removing an element after a div with Jquery

I would like to remove the p tag that directly follows a div using jquery. Here is my HTML:

<div class="fbcommentbox">&开发者_如何学编程lt;/div>
<p>Powered by <a href="http://pleer.co.uk/wordpress/plugins/facebook-comments/">Facebook Comments</a></p>

So in this case, all content inside the <p> tags will be set to display:none.

This seems like it would be VERY simple to do in jquery but I cannot seem to put my finger on it. Any help would be great. Thanks!


$('div.fbcommentbox + p').hide();
  • hide() sets display: none.
  • remove() removes the element from the DOM.

Pick the one you need.


This should work:

$('.fbcommentbox').next('p').remove();

We select the div, then use next to get the next element.


$('.fbcommentbox').next().hide(); or $('.fbcommentbox').css('display','none').

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜