How to get innerhtml of body without an iframe with jquery?

Member

by ryleigh , in category: Javascript , a year ago

How to get innerhtml of body without an iframe with jquery?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by lottie , a year ago

@ryleigh 

You can use the html() method in jQuery to get the innerHTML of the <body> element without using an iframe. Here's an example:

1
2
3
4
$(document).ready(function() {
  var htmlContent = $('body').html();
  console.log(htmlContent);
});


This code will log the innerHTML of the <body> element to the browser console.