Categories
JavaScript Answers

How to change cursor to waiting in JavaScript?

Spread the love

Sometimes, we want to change cursor to waiting in JavaScript.

In this article, we’ll look at how to change cursor to waiting in JavaScript.

How to change cursor to waiting in JavaScript?

To change cursor to waiting in JavaScript, we can set the cursor style.

For instance, we write

document.body.style.cursor = 'wait'

to change the cursor style to spinner.

And we set the cursor style back to the normal style with

document.body.style.cursor = 'default'

We set the style on the body element with both lines so we see the cursor no matter where the mouse is on the page.

Conclusion

To change cursor to waiting in JavaScript, we can set the cursor style.

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 *