How to go full screen on click with JavaScript?

Sometimes, we want to go full screen on click with JavaScript.

In this article, we’ll look at how to go full screen on click with JavaScript.

How to go full screen on click with JavaScript?

To go full screen on click with JavaScript, we use the requestFullscreen method.

For instance, we write

const elem = document.getElementById("myvideo");
elem.requestFullscreen();

to select the element with getElementById.

Then we request the element to go full screen with elem.requestFullscreen.

Conclusion

To go full screen on click with JavaScript, we use the requestFullscreen method.