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,088
  • 27
  • 100
  • 147

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,719
  • 1
  • 25
  • 29