TAG
JavaScript
Result
Run
License
<video id="player" controls src="http://resrc.devdic.com/media/video/movie.mp4"> </video> <div> <label> Volume <span>0</span> <input id="volume" type="range" min="0" max="1" step="0.1" value="0" /> </label> </div> <p><output></output></p>
window.addEventListener("load", function() { const $elPlayer = document.getElementById("player"); const $elOutput = document.querySelector("output"); const $elVolume = document.getElementById("volume"); $elVolume.addEventListener("input", e => { let volume = e.currentTarget.value; $elPlayer.volume = volume; e.currentTarget.previousElementSibling.textContent = volume; }); $elPlayer.addEventListener("volumechange", e => { $elOutput.textContent = `${e.type} event fired.`; }); });
Console
expand_less
License
License
by DevDic
Close