Categories
JavaScript Answers

How to mute an HTML video player using JavaScript?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *