ClassName Toggle JS
document.getElementById('myButton').onclick = function() {
this.classList.toggle('active');
}
Yucky Yak
document.getElementById('myButton').onclick = function() {
this.classList.toggle('active');
}
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;
}
}
document.querySelector('.show-more').addEventListener('click', function () {
document.querySelector('.additional-information')
.classList.toggle('is-visible');
});
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;
}