Top "Getelementsbyclassname" questions

getElementsByClassName is a Javascript function which takes a string argument and returns elements from the current page with a class name matching the string.

How to getElementByClass instead of GetElementById with JavaScript?

I'm trying to toggle the visibility of certain DIV elements on a website depending on the class of each DIV. …

javascript class toggle getelementbyid getelementsbyclassname
Get element inside element by class and ID - JavaScript

Alright, I've dabbled in JavaScript before, but the most useful thing I've written is a CSS style-switcher. So I'm somewhat …

javascript getelementbyid getelementsbyclassname
JS: iterating over result of getElementsByClassName using Array.forEach

I want to iterate over some DOM elements, I'm doing this: document.getElementsByClassName( "myclass" ).forEach( function(element, index, array) { //do …

javascript foreach getelementsbyclassname
How to remove a class from elements in pure JavaScript?

I would like to know how to select all elements with class names "widget" and "hover" and then remove class "…

javascript getelementsbyclassname
What do querySelectorAll and getElementsBy* methods return?

Do getElementsByClassName (and similar functions like getElementsByTagName and querySelectorAll) work the same as getElementById or do they return an array …

javascript getelementsbyclassname dom-traversal
getElementsByClassName to change the style of elements when event occurs

I'm trying to use onmouseover="document.getElementsByClassName().style.background='color'" to change the color of all divs with a given …

javascript css onmouseover getelementsbyclassname
Change value attribute by class via JavaScript

I have the following HTML: <input class="vertical-tabs-active-tab" type="hidden" value="account" name="tabs__active_tab"> I need …

javascript html setattribute getelementsbyclassname
How to get current element in getElementsByClassName

Consider a simple JS event of document.getElementsByClassName('test')[0].onclick=function(){ document.getElementsByClassName('test')[0].innerHTML = 'New Text'; } How can I …

javascript dom-events getelementsbyclassname unobtrusive-javascript
How to add image to button via Javascript?

I am trying to add image to buttons I have using Javascript but I can't seem to get it working. …

javascript html image resources getelementsbyclassname
Use vanilla javascript to add / remove class to a different element after clicking on another one

I have looked through a number of similar questions but can not find a specific example of one that answers …

javascript class getelementsbytagname getelementsbyclassname