About 196,000 results
Open links in new tab
  1. javascript - How to add a class to a given element? - Stack Overflow

    Nov 28, 2016 · element.classList.remove("my-class"); If you need to support Internet Explorer 9 or lower: Add a space plus the name of your new class to the className property of the …

  2. How can I add a class to a DOM element in JavaScript?

    48 3 ways to add a class to a DOM element in JavaScript There are multiple ways of doing this. I will show you three ways to add classes and clarify some benefits of each way. You can use …

  3. How to add/remove a class in JavaScript? - Stack Overflow

    Since element.className property is of type string, you can use regular String object functions found in any JavaScript implementation: If you want to add a class, first use String.indexOf in …

  4. How can I change an element's class with JavaScript?

    How can I change the class of an HTML element in response to an onclick or any other events using JavaScript?

  5. javascript - Is there a way to add/remove several classes in one …

    Jun 20, 2012 · 21 Since the add() method from the classList just allows to pass separate arguments and not a single array, you need to invoque add() using apply. For the first …

  6. how to append a css class to an element by javascript?

    Suppose a HTML element's id is known, so the element can be refereced using: document.getElementById(element_id); Does a native Javascript function exist that can be …

  7. Add class to <html> with Javascript? - Stack Overflow

    Dec 20, 2012 · How do you add a class to the &lt;html&gt; root element using Javascript?

  8. dom - Select and add class in javascript - Stack Overflow

    Cross Platform if possible, how can I select classes in Javascript (but not Jquery please -MooTools is fine though-) on code that I can't add an ID? Specifically, I want to add the class …

  9. JavaScript CSS how to add and remove multiple CSS classes to an …

    Jan 1, 2010 · How can assign multiple css classes to an html element through javascript without using any libraries?

  10. javascript - How to add class to an element create by appendChild ...

    Sep 25, 2012 · I want to ask how to add a class for an element I create by appendChild in javascript Like any other element you have a reference. It doesn't matter if it's created in JS …