Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

135
Views
Change cursor type for an html document from javascript js

Let's say I have a javascript method that takes a little to long to finish to go without any user feedback at all. In my case it's sorting the rows in a table element (all in the DOM; only takes too long if there are a lot of rows), but it might do anything. I want to show the "progress" cursor while it runs. Here is what I have currently, but I've tried several other things as well:

// SORT

document.body.style.cursor = "progress";
MyLongRunningMethod(); //blocks for 10-15 seconds before returning
document.body.style.cursor = "auto";
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Have u tried Promise?maybe that can help u.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise

const MyLongRunningMethod = function(){
            return new Promise((resolve,reject)=>{
                //...dosometing in here
                resolve() //while finish.use the resolve function
            })
        }
      document.body.style.cursor = "progress";
      MyLongRunningMethod().then(res => {
          document.body.style.cursor = "auto";
      }); //blocks for 10-15 seconds before returning

about 4 years ago · Juan Pablo Isaza Report

0

Try this below code;

document.body.style.cursor = "progress";
setTimeout(function(){
SortTable(cell.cellIndex, dir, sortType);
document.body.style.cursor = "auto";}, 10);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!