1

I am new to js and learning how to modify html using js ,i want to modify:

<video controls="" controlslist="download" src="//storage.googleapis.com/media-session/caminandes/short.mp4#t=80">&lt;</video>

To...

<video controls="" controlslist="nodownload" src="//storage.googleapis.com/media-session/caminandes/short.mp4#t=80">&lt; </video>

After the page loads, i want to change controlslist="download" to controlslist="nodownload"

page src:https://googlechrome.github.io/samples/media/controlslist.html

0

1 Answer 1

-1

Use onload event like below

window.onload = function() {

    // select your expected video tag 
    // change attribute controlslist value to expected one 

}

Full Code:

window.onload = function() {
    // select your expected video tag 
    // change attribute controlslist value to expected one 
    var searchString = "t=80";
    var videos = document.getElementsByTagName("video");
    for (let item of videos) {
        if (item.getAttribute("src").includes(searchString)) {
            item.setAttribute("controlslist", "Anything I want")
        }
    }
}
Sign up to request clarification or add additional context in comments.

2 Comments

as you can see at src there are multiple elements so i can't choose src so can you please post the modified code src::googlechrome.github.io/samples/media/controlslist.html
@elite Thanks for your explanation, Added full code. Don't forget to upvote and accept the answer.

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.