Home > other >  how to make a function to change the text back and forward
how to make a function to change the text back and forward

Time:03-28

I just want to change the button text

<button id="reset">Reset</button>
$("#reset').on("click", function () {
this.textContent  = "Loading....";
setTimeOut("this.textContent = " Reset", 2000)
}

after I clicked it will change the text to Loading and in few second it turn back to Reset. I tried to add text

CodePudding user response:

You don't need jQuery.

Just this:

<button id="reset" onclick="this.textContent = 'Loading...'; setTimeout( e => this.textContent = 'Reset', 2000 );">Reset</button>

  • Related