<input type="button" id="myButton" value="NO" onclick="Buttontoggle();"> function Buttontoggle() { var t = document.getElementById("myButton"); if(t.value=="YES"){ t.value="NO"; } else if(t.value=="NO"){ t.value="YES"; } }