Change HTML of an iFrame with jQuery?

You'll have to parse the iframe content.

$("#frameid").contents().find("div").html('My html');

More here : http://api.jquery.com/contents/


You can use contents() to manipulate the contents of the iframe.

$("#frameDemo").contents().find("div").html("new HTML content goes here");

Here is an example from the jQuery documentation:

<!DOCTYPE html>
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
  <iframe src="http://api.jquery.com/" width="80%" height="600" id='frameDemo'></iframe> 
<script>$("#frameDemo").contents().find("a").css("background-color","#BADA55");</script>

</body>
</html>

If you want to change the contents inside the <body> tag of the iframe, you can use this code:

$("#iframe_id").contents().find("body").html('my_new_content');