How to mute an HTML video player using JavaScript?

Sometimes, we want to mute an HTML video player using JavaScript.

In this article, we’ll look at how to mute an HTML video player using JavaScript.

How to mute an HTML video player using JavaScript?

To mute an HTML video player using JavaScript, we set the muted property.

For instance, we write

const video = document.getElementById("your-video-id");
video.muted = true;

to select the video element with getElementById.

We then set muted to true to mute the video.

We write

video.muted = false;

to unmute the video.

Conclusion

To mute an HTML video player using JavaScript, we set the muted property.