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

fraggley
  • 1,215
  • 2
  • 9
  • 19
elite
  • 23
  • 4

1 Answers1

-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")
        }
    }
}
Dipak Telangre
  • 1,792
  • 4
  • 19
  • 46
  • 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::https://googlechrome.github.io/samples/media/controlslist.html – elite May 11 '20 at 05:25
  • @elite Thanks for your explanation, Added full code. Don't forget to upvote and accept the answer. – Dipak Telangre May 11 '20 at 05:41