0

I have a video element with attributes. All I want to do is change those attributes. How do I do this with javascript?

This is my video element with attributes

<video id="VideoElement" src="video/surfing.ogv" controls poster="images/surfing.jpg" width="480" height="300"></video>

2 Answers 2

2

A non-jquery solution:

document.getElementById('VideoElement').attributename = newvalue;
Sign up to request clarification or add additional context in comments.

2 Comments

So for instance, if I want to change the src="" attribute of the video element, I could just write: document.getElementById('VideoElement').src = video/cycling;
... .src = 'video/cycling';, but otherwise, yes.
1
document.getElementById('VideoElement').src = 'myNewSrc.ogv'

Similarly, for other attributes. This solution does not require jQuery

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.