Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7024011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:47:04+00:00 2026-05-27T23:47:04+00:00

I am new to jQuery, and I managed to create a tab interface. I

  • 0

I am new to jQuery, and I managed to create a tab interface. I want each section of my tab to have a YouTube video. However, when I click play on the video that is on tab 1 for example, and then switch to tab 2, the video on tab 1 still keeps on playing. Please see the entire code here:

http://jsfiddle.net/WwfFE/3/

I would greatly appreciate any help on how to stop the video once the user clicks on other tabs.

Also, when I run this on my Android, flash enabled phone, the videos don’t seem to play. Any idea of what I need to do to fix? Or do I need to fix anything else to make code browser compatible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:47:04+00:00Added an answer on May 27, 2026 at 11:47 pm

    This should work:

    http://jsfiddle.net/WwfFE/5/

    I simply put all your URL’s in an array. When the user decides to leave the tab, I clear the src of the iframe so that the video “stops” playing.

    The first time your currentTab variable is still empty though, so I retrieve it by looking at which <li> has its class set to active. From this <li> I take the link and set the currentTab variable to its href.

    if (currentTab == '') {
       //Find current tab:
       currentTab = $('#tabs ul li.active').find('a').attr('href');
    }
    
    //Stop playing video:
    if (currentTab != '')
       $('div#' + currentTab).find('iframe').attr('src', '');
    

    When he gets back to any tab, you should not forget to set the src back though, else your iFrame will be empty. It’s what I do here:

    var index = $(this).attr('id');
    $('div#' + currentTab).find('iframe').attr('src', urls[index]);
    

    This code can still be optimized though to reduce the flickering. An easy way to do this is by setting a function on the load trigger of the iframe‘s. This way you know when the video has been successfully set and it is then that you want to show the tab to the user.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to jQuery and have managed to create a tabbed interface with
I have application that brings response via Ajax and creates 5-20 new jQuery click
I am very new with java script and jQuery and managed to create a
I'm new to jQuery and JavaScript I have managed to get a small snippet
I'm new to jQuery but I managed to get something working. The only thing
Im trying to create a facebook style newsfeed. Using jquery, I've managed to set
I'm fairly new to the whole JQuery/javascript world, but I've managed to wack together
i'm trying to create a modal dialog with jquery mobile rc2. I managed to
When writing a new jQuery plugin is there a straightforward way of checking that
Using jQuery UI 1.8rc3 combined with the new jquery.effects.fade.js code, I've been able to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.