Notification texts go here. Buy Now!

Changing and Loading an Iframe ‘src’ attribute with jQuery

Changing and Loading an Iframe ‘src’ attribute with jQuery

Here is how to change and load an iframe’s src attribute using jQuery:

Select the iframe element:
Use a jQuery selector to target the iframe element. This is commonly done using its ID.

Change the src attribute:
Use the .attr() method to change the src attribute of the selected iframe. Pass ‘src’ as the first argument and the new URL as the second argument

You could use the target attribute on the link to target the iFrame.

If you have the embed links to the youtube videos, you can do something like this:

HTML

JAVASCRIPT

DEMO

Demo

Sources

About the Author

0 Comments

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.