Getting HTML from a div by excluding other divs with jQuery -
we need scrape body of blog articles our system (it's legit, swear - have training blog , want display content in dialogs inside system). blogs written on 3rd party platform produces html so:
<div class="post"> <h3 class="title">title content</h3> <div class="byline"> byline content </div> <div class="submissions"> submission content </div> <div class="buttons"> </div> <p>post body part 1</p> more post body not in tag, user enters <p>even more post body</p> <div class="tags"> tag content </div> </div>
i'm trying html content inside post div, excluding title, byline, submissions, buttons, , tags sections.
if run jquery:
$(".post").not(".title").not(".byline").not(".submissions").not(".buttons").not(".tags").html()
i entire content of post div, including unwanted headers/divs. i've tried various incantations of not, including :not, , googling until eyes hurt, no avail.
any ideas? seems should pretty easy, i'm guessing i'm missing something? thanks!
try using find method :not so
$('div.post').find(":not(.title,.byline,.submissions,.buttons,.tags)");
season taste.
the other option hide unwanted elements:
$('div.post').find('.title, .byline, .submissions, .buttons, .tags').hide();
Comments
Post a Comment