About 16,300 results
Open links in new tab
  1. javascript - How to get html element's class tags - Stack Overflow

    So, I'd like to simply grab the className of the <html> of the page so I can check to see how many no- prefixed classes are present (maybe checking classlist.match(/no-/g).length) and determine if my …

  2. HTML DOM Document getElementsByClassName () Method - W3Schools

    The getElementsByClassName() method returns a collection of elements with a specified class name (s). The getElementsByClassName() method returns an HTMLCollection.

  3. Document: getElementsByClassName() method - Web APIs | MDN

    Jun 3, 2025 · The getElementsByClassName method of Document interface returns an array-like object of all child elements which have all of the given class name (s). When called on the document …

  4. How To Get Element By Class Name In JavaScript - GeeksforGeeks

    Jul 23, 2025 · When working with the DOM in JavaScript, selecting elements by their class names is a common task. JavaScript provides several methods to achieve this, whether we need to select one …

  5. JavaScript get element by class method - Codingy

    The getElementsByClassName () method is a straightforward and efficient way to select elements by class name, particularly when you don’t need the flexibility of more complex CSS selectors.

  6. JavaScript getElementsByClassName () Method

    Use the JavaScript getElementsByClassName() method to select the elements with one or more class names. Was this tutorial helpful ? In this tutorial, you will learn how to use the JavaScript

  7. How to get HTML elements by class using JavaScript

    Mar 29, 2021 · The getElementsByClassName() method always returns an array-like HTMLCollection even if you only have one element with that class name. You can also retrieve elements with more …

  8. How to get elements by class name in JavaScript

    Oct 20, 2025 · From my expertise, document.getElementsByClassName() is the most straightforward method for selecting elements by class. This approach returns a live HTMLCollection that …

  9. How to Get Elements by Class, ID, Tag Name, or Selector in JavaScript

    Apr 30, 2023 · We can assign class names to different DOM elements by using the class attribute. A single element can have multiple space-separated classes. Two or more different DOM elements …

  10. Element: className property - Web APIs | MDN - MDN Web Docs

    Jun 24, 2025 · It is easier to get/set the class attribute of an element using Element.getAttribute and Element.setAttribute if you are dealing with SVG elements. However, take into account that …