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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:45:24+00:00 2026-06-02T12:45:24+00:00

I aim to make a web page with interactive videos, and while searching here

  • 0

I aim to make a web page with interactive videos, and while searching here I came across a link pointing to a jsFiddle that suits my needs.

As the code worked perfectly fine on the jsFiddle, it broke down when i tried to copy it into DreamWeaver (it seems the JavaScript had stopped working).

I had put it all together as such:

<html>
    <script type="text/javascript" src="jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="sgrub.js"></script>
    <script>
        $('#video_1, #video_2').hide();

        $('.icon_1').click(function() {
            $('#video_2').fadeOut(function() {
                $('#video_1').fadeIn();
            });
        });

        $('.icon_2').click(function() {
            $('#video_1').fadeOut(function() {
                $('#video_2').fadeIn();
            });
        });

        $('.icon_1').click(function() {

            $('.video_2').get(0).pause();
            $('.video_2').get(0).currentTime = 0;
            $('.video_1').get(0).play();
        });

        $('.icon_2').click(function() {
            $('.video_1').get(0).pause();
            $('.video_1').get(0).currentTime = 0;
            $('.video_2').get(0).play();
        });

    </script>
    <head></head>
    <body>
        <div class="icon_1" id="mediaplayer">
            cadillac
        </div>
        <div class="icon_2" id="mediaplayer2">
            nike
        </div>
        <div id="video_1">
            <video class="video_1" width="50%" height="50%" controls="controls"
            poster="http://www.birds.com/wp-content/uploads/home/bird.jpg">
                <source src="http://video-js.zencoder.com/oceans-clip.mp4"
                type="video/mp4" />
            </video>
        </div>
        <div id="video_2">
            <video class="video_2" width="50%" height="50%" controls="controls"
            poster="http://www.birds.com/wp-content/uploads/home/bird.jpg">
                <source src="images/01.mp4" type="video/mp4" />
            </video>
        </div>
    </body>
</html>

I have tried wrapping the JavaScript in a jQuery DOM ready call, with no avail:

$(document).ready(function() {
    // The JavaScript here
});
  • 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-02T12:45:26+00:00Added an answer on June 2, 2026 at 12:45 pm

    Your jQuery code is running BEFORE the DOM is ready so your jQuery code doesn’t find any objects in the page so they don’t do anything. You should either locate it at the end of the body AFTER the DOM items are loaded or use jQuery(document).ready() to make your code wait until the DOM is ready.

    Your jsFiddle is set to only run your code after the DOM is loaded so that could be why it works in jsFiddle.

    Change your code to this:

    <script>
    $(document).ready(function() {
    
    $('#video_1, #video_2').hide();
    
          $('.icon_1').click(function(){
                $('#video_2').fadeOut(function(){
                $('#video_1').fadeIn();
                });
          });
    
          $('.icon_2').click(function(){
                $('#video_1').fadeOut(function(){
                $('#video_2').fadeIn();
                });
            });
    
    $('.icon_1').click(function(){
    
                $('.video_2').get(0).pause();
                $('.video_2').get(0).currentTime = 0;
                $('.video_1').get(0).play();
            });
    
    $('.icon_2').click(function(){
                $('.video_1').get(0).pause();
                $('.video_1').get(0).currentTime = 0;
                $('.video_2').get(0).play();
            });
    });
    </script>
    

    You probably also want to fix the location of your script tags. They should either be inside the <head> tags or inside the <body> tags. You have them neither (before <head> tags). Most browsers will likely tolerate, but not technically a good idea.

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

Sidebar

Related Questions

I'm refactoring a .Net web application that is in <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML
Im trying to make some text non-copyable, my aim isn't to stop people from
I have following script which is aim to make a war file. def ant
How can you make a background web request and then update the UI, but
My aim is to make a paint type application. Thank you for your suggestions..
so my aim is to make a IF statement determine what the value of
How do I make robot connect AIM/MSN and stay connected, and respond to a
My aim is to determine the color of object. And make a classification, for
Does anyone know of any existing projects that aim to port Android's Java VM
I'm using URI re-routing in CI to make better URLS. An example here would

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.