Categories
JavaScript Answers

How to go full screen on click with JavaScript?

Spread the love

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.

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 *