Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to change video src attribute values in jQuery?
    primarykey
    data
    text
    <p><br> I'm just wondering how to change src attribute value using jQuery after clicking a link. I want when user click a link on the webpage, a new video will be played as a transition to another page. Here's what my html and jquery look like right now:</p> <pre><code>&lt;script type = "text/javascript" src = "jquery-1.10.2.js"&gt;&lt;/script&gt; &lt;script type = "text/javascript" language = "javascript"&gt; $(document).ready(function() { $("a").click(function() { //alert("Test"); $("#vid source:nth-child(1)").attr("src","Media/bar-transition.mp4"); $('#vid source:nth-child(2)').attr("src","Media/bar-transition.webm"); $('#vid source:nth-child(3)').attr("src","Media/bar-transition.ogv"); $('#vid')[0].play(); }); }); &lt;/script&gt; &lt;body onload = "setTimeout(showIt,3000)"&gt; &lt;div id="main"&gt; &lt;video id="vid" autoplay /&gt; &lt;source src="Media/test-vid-rev.mp4" type="video/mp4" /&gt; &lt;source src="Media/test-vid-rev.webm" type="video/webm" /&gt; &lt;source src="Media/test-vid-rev.ogv" type="video/ogg" /&gt; Your browser do not support the video type &lt;/video&gt; &lt;div class="nav-transition"&gt; &lt;ul id="nav"&gt; &lt;li id="graphic"&gt; &lt;a href="#g"&gt;&lt;/a&gt;&lt;/li&gt; &lt;li id="product"&gt; &lt;a href="#p"&gt;&lt;/a&gt;&lt;/li&gt; &lt;li id="digital"&gt; &lt;a href="#d"&gt;&lt;/a&gt;&lt;/li&gt; &lt;li id="view"&gt; &lt;a href="#v"&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>when I clicked the <code>link("#g","#p",etc),</code> the video source doesn't get changed..is there anything wrong with my jQuery syntax? Can anybody help? I'm a newbie to jQuery..</p> <p>Thx<br> -zangetsKid</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload