/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] need to change attribute value

my html

[code=html]<body>
<div id=”wrapper”>
<video width=”320″ height=”240″ controls>
<source [B]#id=”theVideo”[/B] src=”mp4/Captain_Video03.mp4″ type=”video/mp4″>
Your browser does not support the video tag.
</video><br>
<button id=”btn1″ class=”btn”></button>
<button id=”btn2″ class=”btn”></button>
<button id=”btn3″ class=”btn”></button>
<button id=”btn4″ class=”btn”></button>
<button id=”btn5″ class=”btn”></button>
</div>
<script src=”js.js”></script>
</body>[/code]

my javascript:

(function(){
[B]var theVid = document.getElementById(“theVideo”);[/B]
[].forEach.call(document.getElementsByClassName(‘btn’), function(btn) {
btn.addEventListener(‘click’, function(e) {

switch (e.target.id){
[B] case “btn1”:
theVid.src = “mp4/Captain_Video01.mp4”;
break;
case “btn2”:
theVid.src = “mp4/Captain_Video02.mp4”;
break;[/B]
case “btn3”:
console.log(“button three selected!”);
break;
case “btn4”:
console.log(“button four selected!”);
break;
default:
console.log(e.target.id);
}
})
})

}())

[COLOR=”#B22222″][SIZE=4]When I click on btn1 or btn2 it should change the video in the player. The values of the src attribute is all I’m trying to change.[/SIZE][/COLOR]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@attaboyauthorApr 07.2016 — I found the fix just had to move the id="theVideo" to the video tag.
Copy linkTweet thisAlerts:
@rootApr 07.2016 — This is a duplicate of an existing post you have made.

Please do not make duplicate posts to a forum, your other thread has answers, if you have resolved the issue, please say so in the thread and set the thread marker to resolved, it will save people from attempting to solve your code issue as you solved the problem.

?
×

Success!

Help @attaboy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...