1

How can I modify the poster attribute of a video element with JavaScript?

<video id="vid" poster="AB.png">

2 Answers 2

2

Sure it is:

document.getElementById("vid").setAttribute("poster","newValue");

With jQuery that would be:

jQuery("#vid").attr("poster","newValue");

And it is also a DOM property/id attribute:

document.getElementById("vid").poster = "newValue";

With jQuery that would be:

jQuery("#vid").prop("poster","newValue");
Sign up to request clarification or add additional context in comments.

Comments

1

Yes, poster is an attribute like any other.

In straight JS

document.getElementById("vid").setAttribute("poster","foo");

With jQuery

$('#vid').attr('poster','foo');

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.