Stop function when it says 'GREEN'

rarusfisio

New Member
I am making the button activate the function to change the color to a random color, but when it's green, i want the button to stop changing the color.\[code\]<html><head><script type="text/javascript">function roll1() {rand = Math.ceil(Math.random() * 6);die = document.getElementById("die1");if (rand >= 1 && rand <= 3) { die.innerHTML = "<p>'GREEN'<\/p>";} else if (rand == 4 || rand == 5) { die.innerHTML = "<p>'GREEN'<\/p>";} else if (rand == 6) { die.innerHTML = "<p>'RED'<\/p>"}}</script></head><body><button onclick="roll1()">Roll Dice</button><table><tr><td style="width:55px; height:55px;"><p id="die1">'YELLOW'</p></td></tr></table></body></html>\[/code\]i also don't want the button to disappear, because it still needs to do something else that is not in this code.
 
Back
Top