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

Member

by ryleigh , in category: Javascript , 8 months ago

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

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by lottie , 8 months 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.