How to add iframe to a div with jquery?

Member

by addison , in category: HTML & CSS , 8 months ago

How to add iframe to a div with jquery?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

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

Related Threads:

How to add a <div> above the <iframe>?
How to add css using jquery into iframe?
How to change/add css inside of iframe by jquery?
How to add an <asp:button> to a jquery ui dialog containing an iframe?
How to remove any div in iframe?
How to load iframe in div by ajax?