<!DOCTYPE html>
<html>
<head></head>
<body>
<form>
<input type="button" id="myButton" value="NO"
onclick="Buttontoggle();">
</form>
</body>
<script type="text/javascript">
function Buttontoggle()
{
var t = document.getElementById("myButton");
if(t.value=="YES"){
t.value="NO";}
else if(t.value=="NO"){
t.value="YES";}
}
</script>
</html>
<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";
}
}
<button id="btn"> Click </button>
<p class="demo">YES</p>
<script>
let btn = document.querySelector("#btn");
btn.addEventListener("onclick", function() {
let value = document.querySelctor("#demo").innerHTML;
if(value == "YES"){
document.querySelctor("#demo").innerHTML = "NO";
}else{
document.querySelctor("#demo").innerHTML = "YES";
}
});
</script>