Answers for "toggle class javascript"

0

classname toggle js

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

toggle css class in javascript

/* var or const followed by its name */.getElementById(/* HTML element ID */);
/* var or const's name */.classList.toggle(/* Name of CSS class */);
// I hope this helps!
Posted by: Guest on June-25-2020
13

jquery toggle class

$( "#foo" ).toggleClass( 'className', addOrRemoveOptional );
Posted by: Guest on May-14-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

toggle class in javascript

$('.click-class').click(function() {
    $('.class-toggle').toggle();
    $('.class-toggle').toggleClass('add-class');
})
Posted by: Guest on November-09-2020
0

toggle class to an element javascript

// html <div class="parentElm" id="addActive"></div>

// js
function toggleClass(){
  // get the properties of an element
  var element = document.getElementById("addActive");
  
//  check if the element have class list
  if (element.classList) {
    // add active class if true
   element.classList.toggle("active");
  } else {
   var classes = element.className.split(" ");
   var i = classes.indexOf("active");
  }
 }
Posted by: Guest on July-16-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language