About 212,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 element. First, …

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

    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 any given method …

  3. add class with JavaScript - Stack Overflow

    I am writing some vanilla JavaScript to create a nice navigation menu. I am stuck on adding an active class. I am getting elements by class name NOT by id. The below code works if substituted wit...

  4. javascript - Add another class to a div - Stack Overflow

    I have a function that checks the age of a form submission and then returns new content in a div depending on their age. Right now I am just using getElementById to replace the HTML content. BUt …

  5. How to add Class in javascript using button - Stack Overflow

    3 I want to trying adding class using javascript, I know there is a lot of topic about this in stackoverflow but some of them is too complicated for me to understand, let say I have this simple code this is …

  6. javascript - Add Class to Object on Page Load - Stack Overflow

    Add Class to Object on Page Load Asked 14 years, 9 months ago Modified 8 years, 2 months ago Viewed 148k times

  7. 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?

  8. How to add and remove classes in Javascript without jQuery

    Nov 4, 2014 · I'm looking for a fast and secure way to add and remove classes from an html element without jQuery. It also should be working in early IE (IE8 and up).

  9. 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 used to …

  10. 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 order to check if …