Aryan PrajapatKnowledge Contributor
Create a button element with a value attribute set to “CLICK ME and WAIT” and invoke a click event on the button, which calls a function that changes the button’s text value color to red. At the same time, this function also sets up a timed function using setTimeout() that sets the text color back to black after 5 seconds.
Create a button element with a value attribute set to “CLICK ME and WAIT” and invoke a click event on the button, which calls a function that changes the button’s text value color to red. At the same time, this function also sets up a timed function using setTimeout() that sets the text color back to black after 5 seconds.
function setRed ( )
{
document.getElementById(“Button1”).style.color = “#FF0000”;
setTimeout ( “setBlack()”, 5000 );
}
function setBlack ( )
{
document.getElementById(“Button1”).style.color = “#000000”;
}