<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";
}
}
document.querySelector('.show-more').addEventListener('click', function () {
document.querySelector('.additional-information')
.classList.toggle('is-visible');
});
<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>
let flag = false;
const toggle = () => {
if ( flag ) {
// insert code here when flag is on/true
} else {
// insert code here when flag is off/false
}
flag = ! flag;
}