At the moment i have two buttons one that changes the text to red (default) and the other when clicked changes it to green. Instead of having two buttons I need one button to say green when the text appears red so when you click on the green button it changes the colour to green and then the same button says red now and when clicked it'll change the text to red
THIS IS MY SCRIPT:
function change1() {
txt = document.getElementById("txt");
txt.style.color = 'green';
}
function change2() {
txt = document.getElementById("txt");
txt.style.color = 'red';
}
And these are my buttons
<input type="button" value="Green" onclick="change1()" id="btn">
<input type="button" value="Red" onclick="change2()" id="btn">