Answers for "toggle css class in javascript"

13

jquery toggle class

$( "#foo" ).toggleClass( 'className', addOrRemoveOptional );
Posted by: Guest on May-14-2020
-1

classname toggle js

document.getElementById('myButton').onclick = function() {
    this.classList.toggle('active');
}
Posted by: Guest on July-29-2020
1

toggle class javascript

var menu = document.querySelector('.menu') // Using a class instead, see note below.
menu.classList.toggle('hidden-phone');
Posted by: Guest on March-05-2020
0

how to add toggle class in javascript using css modules

onClick() {
    alert("clicked");
    $('.'+ styles.transform ).toggleClass(styles.transform-active);
  }
Posted by: Guest on May-10-2020
-2

classname toggle js

document.getElementById('myButton').onclick = function() {

    var className = ' ' + myButton.className + ' ';

    if ( ~className.indexOf(' active ') ) {
        this.className = className.replace(' active ', ' ');
    } else {
        this.className += ' active';
    }              
}
Posted by: Guest on July-29-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language