Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

toggle button javascript

<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";
  }
}
Comment

JS toggle

document.querySelector('.show-more').addEventListener('click', function () {
  document.querySelector('.additional-information')
    .classList.toggle('is-visible');
});
Comment

javascript toggle button

<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>
Comment

toggle function in javascript

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;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: js get formatted time 
Javascript :: js reverse 
Javascript :: app script append two list 
Javascript :: filepond remove uploaded file 
Javascript :: perfect scrollbar jquery 
Javascript :: react video srcobject 
Javascript :: javascript variables 
Javascript :: react native layout animation android 
Javascript :: Webpack ReferenceError: process is not defined #871 electron vue 
Javascript :: javascript Check Map Elements 
Javascript :: length of array 
Javascript :: data-toggle="tooltip not working due to jquery-ui.min.js 
Javascript :: javascript events 
Javascript :: javascript string reverse 
Javascript :: what is browse router 
Javascript :: set value of attribute using each and keyup jquery 
Javascript :: javascript date from string dd/mm/yyyy HH mm ss 
Javascript :: node http request 
Javascript :: box shadow generador react native 
Javascript :: create a component in react 
Javascript :: put image in canvas with cover mode 
Javascript :: moment date format 
Javascript :: regex checker 
Javascript :: react hook form 
Javascript :: js delete all from array 
Javascript :: array delete 
Javascript :: vscode regex replace 
Javascript :: regex validations 
Javascript :: flightphp 
Javascript :: dynamic input fields with radio button 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =