How can I make one function to close modals with different content in JS

I have three modals containing a video. Each button opens the same modal but it shows a different video depending on the buttom you clicked. It works fine, but I want to shut off the sound when closing the modal. There is a function to do that named closeVideo(), but it only works for the first modal, and not for the others.
Is there a way to create just one function to shut off the sound of every modal?


<div class="modal">
  <div class="modal-content">
    <span class="btn-close" (click)='closeVideo()'>
        <img src="../../../../../assets/img/close.svg" alt="close">
    </span>
        <iframe id="player" width="560" height="315" src="https://www.youtube.com/embed/N8ABAZvh8WE" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
  </div>
</div>

<div class="modal">
  <div class="modal-content">
    <span class="btn-close" (click)='closeVideo()'>
        <img src="../../../../../assets/img/close.svg" alt="close">
    </span>
        <iframe id="player" width="560" height="315" src="https://www.youtube.com/embed/rn937OyA00g" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
  </div>
</div>

<div class="modal">
  <div class="modal-content">
    <span class="btn-close" (click)='closeVideo()'>
        <img src="../../../../../assets/img/close.svg" alt="close">
    </span>
        <iframe id="player" width="560" height="315" src="https://www.youtube.com/embed/EUjWFr3w7RU" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
  </div>
</div>


  closeVideo(){
    let myPlayer = document.getElementById('player');
    myPlayer.setAttribute("src", " ");
    console.log('video is closed now!');
  }

8,107 thoughts on “How can I make one function to close modals with different content in JS”

  1. I’ve been surfing online more than 3 hours today, but I never found any attention-grabbing article like yours.
    It’s beautiful price sufficient for me. In my view, if all web owners and bloggers made good content as you probably did, the web will be
    much more useful than ever before.

    Reply
  2. Pingback: canadianmed cialis
  3. Pingback: cheap viagra
  4. Hi this is kind of of off topic but I was wondering if blogs use
    WYSIWYG editors or if you have to manually code with HTML.

    I’m starting a blog soon but have no coding experience so I wanted to get guidance from someone with experience.
    Any help would be enormously appreciated!

    Reply
  5. Today, I went to the beach front with my kids. I found a sea shell and gave it to my 4 year old daughter
    and said “You can hear the ocean if you put this to your ear.”
    She put the shell to her ear and screamed. There was a hermit crab inside and it pinched her
    ear. She never wants to go back! LoL I know this is completely off topic but
    I had to tell someone!

    Reply
  6. It’s perfect time to make a few plans for the future and it’s time to be happy.
    I’ve read this put up and if I may just I desire to suggest you few interesting issues or advice.
    Perhaps you can write subsequent articles relating to this article.

    I desire to learn even more things about it!

    Reply
  7. I have been surfing online more than 2 hours today, yet I never found any
    interesting article like yours. It’s pretty worth enough for me.
    In my opinion, if all site owners and bloggers made good content as you did, the internet will
    be a lot more useful than ever before.

    Reply
  8. I just could not leave your site before suggesting that I actually enjoyed the standard
    information an individual supply in your guests? Is going to be again often to check up on new posts

    Reply
  9. Good blog post. Some tips i would like to add is that laptop or computer memory needs to be purchased should your computer can no longer cope with whatever you do by using it. One can put in two RAM memory boards with 1GB each, by way of example, but not certainly one of 1GB and one of 2GB. One should make sure the maker’s documentation for the PC to ensure what type of memory is necessary.

    Reply
  10. I just couldn’t leave your website before suggesting
    that I actually enjoyed the standard information an individual
    supply for your guests? Is going to be back continuously to
    investigate cross-check new posts

    Reply
  11. I have been surfing online more than 2 hours today, yet I never found any interesting article
    like yours. It’s pretty worth enough for me. In my view,
    if all site owners and bloggers made good content as you did, the net will be a lot more useful than ever before.

    Reply
  12. I will right away snatch your rss feed as I can’t in finding your email subscription hyperlink or newsletter service.
    Do you have any? Please allow me know so that I may just subscribe.
    Thanks.

    Reply
  13. I’ve been browsing online more than three hours lately, but I never discovered any fascinating article like yours.

    It is lovely worth enough for me. In my opinion, if all website owners and
    bloggers made good content material as you probably did,
    the web will be much more helpful than ever before.

    Reply
  14. Oh my goodness! Incredible article dude! Thank
    you so much, However I am going through difficulties with your RSS.
    I don’t understand the reason why I can’t join it. Is there anybody else getting identical RSS issues?
    Anyone that knows the answer will you kindly respond? Thanks!!

    Reply
  15. Woah! I’m really enjoying the template/theme of this blog.
    It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and
    appearance. I must say that you’ve done a very good job with this.
    Additionally, the blog loads very fast for me on Firefox.
    Exceptional Blog!

    Reply
  16. It is the best time to make some plans for the future and it is time to be happy.
    I have read this submit and if I may I desire to counsel
    you few interesting issues or suggestions. Perhaps you
    could write subsequent articles regarding this article.
    I desire to learn even more issues approximately it!

    Reply
  17. I’ll right away snatch your rss as I can’t find your e-mail subscription link or newsletter service.
    Do you’ve any? Please permit me understand in order that I may subscribe.

    Thanks.

    Reply
  18. I really like what you guys are usually up too. This sort of clever work and reporting!
    Keep up the terrific works guys I’ve included
    you guys to my own blogroll.

    Reply
  19. I have been browsing online more than 4 hours today, yet I never found any
    interesting article like yours. It is pretty worth enough
    for me. Personally, if all site owners and bloggers made good content as you did, the net
    will be a lot more useful than ever before.

    Reply
  20. Howdy! I could have sworn I’ve been to this web site before but after looking at some of the posts I
    realized it’s new to me. Nonetheless, I’m definitely pleased I stumbled upon it and I’ll be book-marking it and checking
    back often!

    Reply
  21. Hello there, I discovered your site via Google at the same time as
    looking for a related matter, your site got here
    up, it seems good. I have bookmarked it in my google bookmarks.

    Hi there, just turned into alert to your blog via Google, and located
    that it’s truly informative. I’m going to be careful for brussels.
    I will be grateful if you proceed this in future. Many other folks will be benefited
    out of your writing. Cheers!

    Reply
  22. I absolutely love your blog.. Pleasant colors & theme.
    Did you create this amazing site yourself? Please reply
    back as I’m attempting to create my own blog and would love to find out where you
    got this from or what the theme is called. Appreciate it!

    Reply
  23. My programmer is trying to convince me to move to .net from PHP.
    I have always disliked the idea because of the expenses.
    But he’s tryiong none the less. I’ve been using Movable-type on numerous websites for about a
    year and am concerned about switching to another platform.
    I have heard very good things about blogengine.net. Is there a way I can import all my wordpress content
    into it? Any kind of help would be really appreciated!

    Reply
  24. I have been surfing online more than 2 hours today, yet I never
    found any interesting article like yours.

    It is pretty worth enough for me. In my view, if all webmasters and
    bloggers made good content as you did, the internet will be much more useful than ever before.

    Reply
  25. Hello! Someone in my Facebook group shared this site
    with us so I came to take a look. I’m definitely enjoying the information. I’m
    bookmarking and will be tweeting this to my followers!
    Terrific blog and superb design and style.

    Reply
  26. I have been browsing online greater than 3 hours
    today, yet I by no means discovered any attention-grabbing
    article like yours. It is beautiful price enough for me.
    In my opinion, if all web owners and bloggers made just right content as you did,
    the web might be a lot more useful than ever before.

    Reply
  27. [url=http://azcialis.com/]order real cialis[/url] [url=http://nolvadexpill.com/]cheap tamoxifen[/url] [url=http://viagraiix.com/]viagra 200[/url] [url=http://tadalafilworx.com/]how much is tadalafil 5mg[/url] [url=http://cheapestsildenafil.com/]sildenafil purchase[/url]

    Reply
  28. It is the best time to make some plans for
    the future and it’s time to be happy. I’ve
    learn this publish and if I could I desire to suggest you some attention-grabbing
    issues or suggestions. Perhaps you can write
    next articles referring to this article. I want to learn more things approximately it!

    Reply
  29. I drop a comment when I appreciate a article on a site or I have something to contribute to the discussion. Usually it’s caused by the sincerness displayed in the article I read.
    And after this post The Growing Trends in Content Theft: Image Theft, Feed Scraping, and Website Hijacking ?
    Lorelle on WordPress. I was actually excited enough to drop
    a comment 🙂 I do have a couple of questions for you if you don’t mind.

    Is it just me or do a few of these responses appear like coming from
    brain dead individuals? 😛 And, if you are posting at other social sites, I’d like to keep up with you.
    Would you make a list every one of your public
    sites like your linkedin profile, Facebook page or twitter feed?

    Reply
  30. [url=https://vdphealth.com/]buy lasix online cheap[/url] [url=https://medicinecialis.com/]cialis tadalafil 20 mg[/url] [url=https://ivermectinzt.com/]ivermectin usa[/url] [url=https://opivermectin.com/]ivermectin 3mg tablet[/url] [url=https://buysildenafilpills.com/]sildenafil 20 mg tablets coupon[/url] [url=https://aventolin.com/]albuterol from india[/url]

    Reply
  31. Greetings from Carolina! I’m bored at work so I decided
    to check out your blog on my iphone during lunch break. I enjoy the information you provide here and can’t wait to take a
    look when I get home. I’m shocked at how fast your blog loaded on my mobile ..

    I’m not even using WIFI, just 3G .. Anyhow, awesome
    blog!

    Reply
  32. Hi,i think thuat i saww yyou visoted myy weeb sikte thus i casme too “return the favor”.I’m attempting tto
    fjnd thbings tto enance myy web site!I sulpose itss ook too uuse ome off your ideas!

    Reply
  33. It is appropriate time to make some plans for the future and
    it’s time to be happy. I’ve read this post and if I could I want to suggest you some interesting things or suggestions.
    Maybe you can write next articles referring to this article.
    I want to read more things about it!

    Reply
  34. I’ve been surfing online greater than 3 hours today, but I by no means found
    any interesting article like yours. It is lovely worth enough for me.
    In my opinion, if all web owners and bloggers made just right content as you probably did, the internet shall
    be a lot more useful than ever before.

    Reply
  35. Do you have a spam problem on this site; I also am a blogger, and I was curious about your situation; many of us have
    created some nice methods and we are looking to trade strategies with others, please shoot me an email if interested.

    Reply
  36. It’s the best time to make a few plans for the future and
    it’s time to be happy. I’ve learn this put up and if I could
    I wish to counsel you few attention-grabbing things
    or tips. Perhaps you could write next articles relating to
    this article. I want to learn more issues about it!

    Reply
  37. I will immediately snatch your rss feed as I can not to find your e-mail subscription hyperlink or e-newsletter
    service. Do you’ve any? Please permit me realize so that
    I may subscribe. Thanks.

    Reply
  38. I’ve been surfing online more than 2 hours today, yet I never found any interesting article like yours.
    It’s pretty worth enough for me. In my opinion,
    if all webmasters and bloggers made good content as you did, the net will
    be much more useful than ever before.

    Reply
  39. Its such as you read my thoughts! You seem to understand so much approximately this, like
    you wrote the book in it or something. I think that you simply can do with
    a few p.c. to pressure the message house a little
    bit, however other than that, that is fantastic blog.
    An excellent read. I will definitely be back.

    Reply
  40. Can I just say what a relief to find someone who actually knows what theyre talking about on the internet. You definitely know how to bring an issue to light and make it important. More people need to read this and understand this side of the story. I cant believe youre not more popular because you definitely have the gift.

    Reply
  41. Thanks for the sensible critique. Me & my neighbor were just preparing to do some research on this. We got a grab a book from our local library but I think I learned more clear from this post. I am very glad to see such wonderful info being shared freely out there.

    Reply