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()
setsdisplay: 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')
.
精彩评论