Dom force rendering of an element

I need to change part of the text of a Button before starting a process (twain scan) and rewriting the original text after the process finished. It seems I need to force in some way the rendering of the button before the process start and I don't know how (I tried with setTimeout but with no success). I try a simple test with an alert in place of the process and it's doing the same thing. It's working if I put a breakpoint before the alert but not without bkpt.I would like really what is behind this problem and a way of working around in a Long-lasting solution (in case of browser update)

<div id="hidebtn" class=" col-sm-11 ">
  <button id="btn-scan" type="button" class="btn btn-primary  col-sm-offset-2   col-sm-8">SCAN<br><span id ="span-piece-std">DOCUMENT</span></button>

var textBtnScan="";

document.querySelector('#btn-scan').onclick = function () {  
    alert("something is processing");

function debutScan(){ 
    textBtnScan =  $("#span-piece-std").text();
    $("#span-piece-std").text(" Running......");
function finScan(){