Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to get a toggle button to do different js functions

var clicked = false;

function toggleBtnClick() {
  var img = document.getElementById('baseImg');
  if (clicked) {
    img.src = 'http://via.placeholder.com/350x150/e9e9e9/000000';
    clicked = false;
  } else {
    img.src = 'http://via.placeholder.com/350x150/3fafed/000000';
    clicked = true;
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: get id of element javascript 
Javascript :: using multiparty with node js express 
Javascript :: include other js files in a js file 
Javascript :: unfocus javascript 
Javascript :: how hide .html in url 
Javascript :: deserialize json jquery 
Javascript :: how to manage a db connection in javascript 
Javascript :: mv multiple directories 
Javascript :: toggle button javascript 
Javascript :: disable button in jsx 
Javascript :: react native keyboard event listener 
Javascript :: To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect 
Javascript :: reactstrap form post 
Javascript :: how to change the color of a console.log in javascript 
Javascript :: npx create-express-api 
Javascript :: how to get the data from url in javascript 
Javascript :: jquery form data 
Javascript :: js is boolean 
Javascript :: set cookie and get cookie in javascript 
Javascript :: header logo react native img 
Javascript :: emailjs react npm 
Javascript :: updateone mongoose example 
Javascript :: javascript fs read 
Javascript :: ionic react use yarn 
Javascript :: suspense react 
Javascript :: query string from object js 
Javascript :: number_format in jquery 
Javascript :: react prevent component from update once mounted 
Javascript :: convert an array to string javascript 
Javascript :: strict mode in javascript 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =