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 9156289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:44:26+00:00 2026-06-17T12:44:26+00:00

I dont know a lot of javascript but I wonder if this is possible:

  • 0

I dont know a lot of javascript but I wonder if this is possible:

I need the videos to be invisible and when I press one of my links a youtube embed fades in (and starts playing). Then when I mouseOver and mouseOut I want it to fade out and then be able to fade in again on mouseOver, but I don’t get it to work. I’ve had different results where the div seems to disappear (when I mouse over where the player used to be nothing fades in) and now im stuck at this:

Here is how far I’ve come with looking around here on stackoverflow for solutions:

Here’s a jsFiddle > http://jsfiddle.net/VKzxy/

And my jQuery:

/* elt: Optionally, a HTMLIFrameElement. This frame's video will be played,
     *       if possible. Other videos will be paused*/
    function playVideoAndPauseOthers(frame) {
        $('iframe[src*="http://www.youtube.com/embed/"]').each(function(i) {
            var func = this === frame ? 'playVideo' : 'pauseVideo';
            this.contentWindow.postMessage('{"event":"command","func":"' + func + '","args":""}', '*');
        });
    }
    $('#links a[href^="#vid"]').click(function() {
        var frameId = /#vid(\d+)/.exec($(this).attr('href'));
        if (frameId !== null) {
            frameId = frameId[1]; // Get frameId
            playVideoAndPauseOthers($('#playlist' + frameId + ' iframe')[0]);
                        $($('#playlist' + frameId + ' iframe')[0]).fadeIn(750);
                        //When hovering, fadeIn.
                        $('#content').mouseenter(function(){
                                $($('#playlist' + frameId)[0]).fadeIn(750);
                        });
                        //When leaving, fadeOut.  
                        $($('#playlist' + frameId)[0]).mouseleave(function(){
                                $($('#playlist' + frameId)[0]).fadeOut(750);
                        });
        }
    });

edit: It does not have to be in javascript, any solution that works will be fine.

  • 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-06-17T12:44:27+00:00Added an answer on June 17, 2026 at 12:44 pm

    you need to:

    • pause all videos

    • hide them all

    • show desired video

    • play desired video

    Here you go:

    http://jsfiddle.net/5Yxhj/6/

    NOTE

    for the fade effect to work you have to set wmode to opaque, just like in the jsfiddle example.

    src="http://www.youtube.com/embed/a-TrP8Z3Cb8?wmode=opaque& (...)
    

    this will allow jQuery’s changes in opacity levels (actually this is what happens when calling fadeIn or fadeOut) to also show on top of the flash object. (actually when the iframe opacity changes).

    HERE IS THE JS CODE THAT’S IN THE FIDDLE

    function hideAll()
    {
        $('#content').children('div').each(function()
        {
            $(this).hide();
        });
    }
    
    function fadeAll(strClickId)
    {
        var elems = $('#content').children('div'), count = elems.length;
    
        elems.each(function()
        {
            $(this).fadeOut(750, function()
            {
                $(this).children('iframe')[0].contentWindow.postMessage(
                    JSON.stringify({
                        "event": "command",
                        "func": "pauseVideo",
                        "args": ""
                    }), "*"
                );
                if (!--count)
                {
                    $(strClickId).fadeIn(750, function()
                    {
                        $(strClickId).children('iframe')[0].contentWindow.postMessage(
                            JSON.stringify({
                                "event": "command",
                                "func": "playVideo",
                                "args": ""
                            }), "*"
                        );
                    });
                }
            });
        });
    }
    
    $(window).load(function()
    {
        hideAll();
    });
    
    $('#links a[href^="#vid"]').click(function()
    {    
        var frameId = '#playlist' + $(this).attr('href').substr(4);
        fadeAll(frameId);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there is a lot of thread about this problem but I dont
I dont know if this is possible. In SSIS Derived column transformation, can you
I know this type of question has been asked a lot, but I really
I don't know a lot about flash, but I do know asp.net and javascript,
I've been working a lot lately with perl, still I dont really know how
I know a lot about python but I don't know all the aspect to
I don't know a lot about how the iOS handles URLs, but it appears
I dont know what happend but I cant register any dlls anymore. It seems
I'm a backend programmer and I wonder about one thing. I know just a
I don't know much about jquery but I know this is the only way

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.