DOM refresh on long running function

后端 未结 12 2350
醉话见心
醉话见心 2020-11-27 20:54

I have a button which runs a long running function when it\'s clicked. Now, while the function is running, I want to change the button text, but I\'m having problems in some

12条回答
  •  长情又很酷
    2020-11-27 21:20

    Try this

    function longRunningTask(){
        // Do the task here
        document.getElementById("mybutt").value = "done";
    }
    
    function longrunningfunction() {
        document.getElementById("mybutt").value = "doing some work";
    
        setTimeout(function() {
            longRunningTask();
        }, 1);    
    }
    

提交回复
热议问题