Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

toggle button by javascript

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

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

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

PREVIOUS NEXT
Code Example
Javascript :: check if an object contains a value in javascript 
Javascript :: local storal javascript 
Javascript :: sort by json fied in laravel 
Javascript :: javascript map Removing Elements 
Javascript :: textField input font color React Material UI 
Javascript :: cypress click 
Javascript :: truncate a string 
Javascript :: jboss session expiration time 
Javascript :: js display 2d array 
Javascript :: generate thumbnail of pdf using pf js 
Javascript :: update file json trong javascript 
Javascript :: find duplicate values in array object javascript 
Javascript :: map function in react 
Javascript :: javascript get first 3 characters of string 
Javascript :: jquery get closest form 
Javascript :: animate jquery 
Javascript :: Unable to locate package node 
Javascript :: javascript remove last element from array 
Javascript :: count array in javascript 
Javascript :: queue en js 
Javascript :: Regular expression: Match everything after a particular word 
Javascript :: jquery select option by text 
Javascript :: js read from json2 
Javascript :: insert item into array specific index javascript 
Javascript :: permutation javascript 
Javascript :: vue 3 computed getter setter 
Javascript :: how to change the color of error message in jquery validation 
Javascript :: npm run shell script 
Javascript :: semantic ui dropdown value react 
Javascript :: check date in between two dates nodejs 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =