0

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?

Francesco
  • 24,839
  • 29
  • 105
  • 152

1 Answers1

6

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()
ori
  • 7,817
  • 1
  • 27
  • 31