How to add iframe to a div with jquery?

Member

by addison , in category: HTML & CSS , 19 days ago

How to add iframe to a div with jquery?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by domenico , 18 days ago

@addison 

To add an iframe to a div using jQuery, you can use the following code snippet:

1
2
3
$(document).ready(function(){
   $("#yourDivId").append('<iframe src="https://www.example.com"></iframe>');
});


Replace "#yourDivId" with the ID of the div where you want to add the iframe and "https://www.example.com" with the URL of the webpage you want to display in the iframe.


This code will append an iframe element to the specified div when the document is ready.