Jquery: get all html source of a page but excluding some #ids

I'm trying to use .html() or .contents() but i have strange behaviours

I basically need to get the entire dom of the page, exclude some elements (ex. #first, #second) and the pass it as a string, not a dom anymore...

is it possible?

Answers:

Answer

You can clone it, remove the elements you want to exclude from the clone, and then return the clone's html:

$('body').clone().find('#first,#second').remove().end().html()

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.