I built a playlist of videos in jQuery and it is working, but not as expected, where is the error?

Asked

Viewed 37 times

0

I am an industrial designer (designer and illustrator) by training and I am not a programmer, but I like to learn about technology and programming. I built, with the help of jQuery tutorials on the internet, a "playlist" of videos, the basic idea would be to click on one of the items below and change the video above, changing the SOURCE of the video’s IFRAME. It’s working, the switch happens when you click, but the video is opening on another page, instead of changing on top of the video itself and on the same page. What’s wrong? Thanks for your help and a strong hug.

    $(document).ready(function() {
    
        $("#listagem li a").click(function(e) {
    
            e.preventDefault();
    
            $(".video iframe").attr("src", $(this).attr("href"));
    
        });
    
    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- PLAYER de vídeo -->
    <div class="video">

       <iframe width="" height="" src="https://www.youtube.com/embed/qdIdPBIF6MU" frameborder="0" allow="encrypted-media" allowfullscreen=""></iframe>

    </div>

    <!-- LINKS -->
    <ul id="listagem"><li><a href="https://www.youtube.com/watch?v=qdIdPBIF6MU&feature=youtu.be" id="aula1">Aula 1 <br/> <h3>Título da aula 1</h3></a></li><li><a href="https://www.youtube.com/watch?v=rfh0cpyv6hc" id="aula2">Aula 2 <br/> <h3>Título da aula 2</h3></a></li><li><a href="https://www.youtube.com/watch?v=9hFhYjmPfAk" id="aula3">Aula 3 <br/> <h3>Título da aula 3</h3></a></li><li><a href="https://www.youtube.com/watch?v=9hFhYjmPfAk" id="aula4">Aula 4 <br/> <h3>Título da aula 4</h3></a></li></ul>

  • these links should not be embed?

  • What do you mean? I don’t understand.

  • maybe I’m confusing it, but when you copy a yt link to put on your website it shouldn’t be :https://www.youtube.com/EMBED/iddoyoutube

  • type, your first iframe is in this pattern, but the links are not

  • He uploads the videos only on another page. I used the EMBED embedding pattern, as you described and also did not work, continue opening on the other page.

  • I just tested doing exactly that where I said on your links and it worked, I’m using Chrome version 69

  • thus : <a href="https://www.youtube.com/embed/rfh0cpyv6hc" id="aula2">Aula 2 <br/> <H3>Title of class 2</H3></a></li><li>

  • Thanks! Thank you, Lucas! I’ll test.

  • if it works out nicely signals me to leave as an answer

  • Lucas, I found out what was wrong! Missing attributes: NAME on target and TARGET on class links. I touched this and it’s working! Thanks, man, thanks for your help!

Show 5 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.