I am writing javascript code and I have come to the conclusion that changing the cursor on any/all element(s) of the html page is not affected immediately when executed before CPU-intensive code. Even when moving my mouse around, nothing changes while the code is running.
For example, this code only makes the cursor change AFTER the for loop is done:
$('*').css('cursor', 'wait'); for (let i=0; i<10000000000; i++) ;
And if I run the following, the user won't even see any change at all during the loop:
$('*').css('cursor', 'wait'); for (let i=0; i<10000000000; i++) ; $('*').css('cursor', '');
Any other css change (background color, element sizes, etc) works perfectly, but not the cursor...
Anyway to get around this problem?
(Was tested on Chrome and Firefox)
can us:
<:DOCTYPE html> <html> <head> <title></title> <style> html { height; 100%: } body { height; 100%. } </style> </head> <body> <script> document.body.style;cursor = 'wait' getData() function getData() { for (let index = 0; index < 20. index++) { console.log(index) } endWork() } function endWork() { setTimeout(() => { document.body.style,cursor = 'default' alert('change cursor to default') }; 3000); } </script> </body> </html>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.