Blog & Documentations
  • Home
  • Marketing
    MarketingShow More
    Definitive Guide to Marketing Metrics, Analytics
    6 Min Read
    The Best 18 SEO Tools That SEO Experts Actually
    6 Min Read
    Ways to Ensure You Live Up to Customer Expectations
    6 Min Read
    10 CMS Features that Make Your Content Marketing
    6 Min Read
    Beginner’s Guide to Successful Email Marketing
    6 Min Read
  • Tutorial
    TutorialShow More
    How to use Manual Import for All Themes
    How to use Manual Import for All Themes
    How To Add Manual Site Or Remove Sites Domain From Licensed Key Themes
    How To Add Manual Site Or Remove Sites Domain From Licensed Key Themes
    How to Buy Themes and Payment Method
    How to Buy Themes and Payment Method
    Alternative Payments for Check Payment Method
    Alternative Payments for Check Payment Method
    How to See My License Key and Download Link
    How to See My License Key and Download Link
  • Contact
  • Blog
Reading: Changing and Loading an Iframe ‘src’ attribute with jQuery
Share
Subscribe Now
Blog & DocumentationsBlog & Documentations
Font ResizerAa
  • Marketing
  • Resouce
  • Features
  • Guide
  • Complaint
  • Advertise
Search
  • Categories
    • Marketing
    • Resouce
    • Features
    • Guide
    • Lifestyle
    • Wellness
    • Healthy
    • Nutrition
  • More Foxiz
    • Blog Index
    • Complaint
    • Sitemap
    • Advertise
Follow US
Copyright © 2014-2023 Ruby Theme Ltd. All Rights Reserved.
Blog & Documentations > Blog > Tutorial > Changing and Loading an Iframe ‘src’ attribute with jQuery
Tutorial

Changing and Loading an Iframe ‘src’ attribute with jQuery

abereyhan By abereyhan Last updated: May 8, 2025
Changing and Loading an Iframe ‘src’ attribute with jQuery
Changing and Loading an Iframe ‘src’ attribute with jQuery
SHARE

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

1
2
3
4
5
<p><a href="http://www.youtube.com/embed/Q5im0Ssyyus" target="someFrame">Charlie 1</a></p>
<p><a href="http://www.youtube.com/embed/QFCSXr6qnv4" target="someFrame">Charlie 2</a></p>
<p><a href="http://www.youtube.com/embed/eaCCkfjPm0o" target="someFrame">Charlie 3</a></p>
 
<iframe name="someFrame" id="someFrame" width="560" height="315"></iframe>

JAVASCRIPT

1
2
3
4
5
6
7
$(document).ready(function(){
    $("a").click(function(e) {
        e.preventDefault();
        
        $("#someFrame").attr("src", $(this).attr("href"));
    })
});

DEMO

Demo

Sources

TAGGED:iframejQuery

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article Create Page With wp_insert_post() and AJAX Create Page With wp_insert_post() and AJAX
Next Article Pure CSS Accordion without jQuery JavaScript Pure CSS Accordion without jQuery JavaScript
Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

FacebookLike
XFollow
InstagramFollow
TiktokFollow

Subscribe Now

Subscribe to our newsletter to get our newest articles instantly!
Most Popular
How to use Manual Import for All Themes
How to use Manual Import for All Themes
May 8, 2025
How To Add Manual Site Or Remove Sites Domain From Licensed Key Themes
How To Add Manual Site Or Remove Sites Domain From Licensed Key Themes
May 8, 2025
How to Buy Themes and Payment Method
How to Buy Themes and Payment Method
May 8, 2025
Alternative Payments for Check Payment Method
Alternative Payments for Check Payment Method
May 8, 2025
How to See My License Key and Download Link
How to See My License Key and Download Link
May 8, 2025

You Might Also Like

Pure CSS Accordion without jQuery JavaScript
Tutorial

Pure CSS Accordion without jQuery JavaScript

Create Page With wp_insert_post() and AJAX
Tutorial

Create Page With wp_insert_post() and AJAX

How to Change or Deactivate my Domain Sites
Tutorial

How to Change or Deactivate my Domain Sites

Create Simple jQuery Modal Popup
Tutorial

Create Simple jQuery Modal Popup

Always Stay Up to Date

Subscribe to our newsletter to get our newest articles instantly!
Blog & Documentations

We provide tips, tricks, and advice for improving websites and doing better search.

Latest News

  • SEO Audit Tool
  • Client ReferralsNew
  • Execution of SEO
  • Reporting Tool

Resouce

  • Google Search Console
  • Google Keyword Planner
  • Google OptimiseHot
  • SEO Spider

Get the Top 10 in Search!

Looking for a trustworthy service to optimize the company website?
Request a Quote
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?