getelementsbyclassname Questions
4
I have HTML
Name 1:<input type="text" class="one" id="mytext">
<button onclick="disfunction()"></button>
Javascript
function disfunction(){
document.getElementsByClassName("on...
Trillby asked 9/4, 2015 at 7:39
8
Solved
I'm trying to toggle the visibility of certain DIV elements on a website depending on the class of each DIV. I'm using a basic JavaScript snippet to toggle them. The problem is that the script only...
Afteryears asked 19/12, 2009 at 17:38
14
Solved
I want to iterate over some DOM elements, I'm doing this:
document.getElementsByClassName( "myclass" ).forEach( function(element, index, array) {
//do stuff
});
but I get an error:
document....
Mucky asked 6/10, 2010 at 10:28
8
Solved
Alright, I've dabbled in JavaScript before, but the most useful thing I've written is a CSS style-switcher. So I'm somewhat new to this. Let's say I have HTML code like this:
<div id="foo&q...
Northwest asked 19/10, 2011 at 0:45
12
Solved
Do getElementsByClassName (and similar functions like getElementsByTagName and querySelectorAll) work the same as getElementById or do they return an array of elements?
The reason I ask is because...
Piling asked 21/5, 2012 at 23:17
6
Please refer fiddle - http://jsfiddle.net/fkwwyvz8/
x = document.getElementsByClassName("buddy_blocks");
for(i=0;i<x.length;i++)
x[i].remove();
Click on the last button, and it had to remove...
Swaney asked 4/2, 2015 at 8:1
9
Solved
I would like to know how to select all elements with class names "widget" and "hover" and then remove class "hover" from these elements.
I have the following JavaScript code that selects all eleme...
Sorcim asked 8/3, 2014 at 14:40
2
Solved
I am using LitElement to create custom Web Components. I am fairly new at it and decided to try making image slideshow. I used W3Schools slideshow as reference
while modifying it to work as LitElem...
Jarboe asked 24/11, 2018 at 17:46
2
Solved
In the following simple HTML, I would like to get all elements with class1 but not with class2.
<li class="class1 class2"></li>
<li class="class1 class3"></li>
<li class...
Cucurbit asked 21/10, 2013 at 11:0
2
Solved
I need to get all innerText of all elements that partially match a given string.
Heres a snippet of the code:
<span class="18794221455sarasa">Some text</span>
The class always ends ...
Reeva asked 14/2, 2020 at 20:52
4
Solved
I'm trying to only show certain divs. The way I have decided to do this is to first hide all elements that start with "page" and then only show the correct divs. Here's my (simplified) code:
<f...
Mosher asked 4/4, 2016 at 7:10
2
I have a few divs with class='class_name', and also have declared
var A = document.getElementsByClassName('class_name');
console.log(A[0]);
The Chrome console shows:
<div class="class_name"...
Sworn asked 28/7, 2017 at 12:15
3
I know this has been asked many times, but haven't seen a clear answer for looping thru a div and findind tags with the same classname.
My first question:
If I have something like this:
<div ...
Coady asked 10/9, 2013 at 2:38
2
Solved
I have been trying to create a slideshow on one of the web pages I've been creating. I have created a div with a unique class name that is targeted in order to change the background image using Jav...
Eximious asked 15/3, 2018 at 0:7
2
Solved
I've got a nodelist of objects returned by a call to document.getElementsByClassName('a'). Some of these objects have an extra class b. How can I create an array of elements that contain both class...
Vassaux asked 20/1, 2017 at 20:39
2
Solved
I have looked through a number of similar questions but can not find a specific example of one that answers in vanilla JS how to add and remove a class to a different element from the one clicked o...
Culch asked 9/1, 2017 at 14:49
2
Solved
I've written a script, it's goal is to stop displaying images one and two, while allowing image 3 to remain displayed and move into their place. It works fine when I use div Id's instead of d...
Narcis asked 27/8, 2016 at 6:23
2
Solved
Its so plain simple, I can not comprehend, what is the issue?
All DOMs are created before I pick them, used either a document.getElementsByClass or just the dom object created itself, not wor...
Pettifog asked 18/4, 2016 at 20:2
6
Solved
I am trying to add image to buttons I have using Javascript but I can't seem to get it working. I have sucessfully added image using HTML5, however, for my needs I need to add the image via javascr...
Catechize asked 2/3, 2016 at 8:43
3
Solved
I need a little help as i am getting frustrated with .getElementsByClassName.
I have an svg map that has paths with classes. I now need to list all with a certain class and add another class. Right...
Librium asked 22/7, 2014 at 21:2
3
Solved
I wrote a function to change the class of elements to change their properties. For some reason, only some of the elements have changed. It took me a few hours to find a solution, but it seems odd t...
Abysm asked 22/3, 2013 at 3:58
3
Solved
I'm trying to add a extra class to some elements with a specific class(input-fieldset).
<fieldset id="pay" class="input-fieldset"></fieldset>
<fieldset id="address" class="inp...
Bhatt asked 14/6, 2014 at 12:1
2
Solved
Is it possible to get elements that have one of the specified classes? This is not the same as getting elements that have all of the specified classes.
For example, I want to capture all elements ...
Toniatonic asked 18/2, 2014 at 12:32
3
Solved
I have the following HTML:
<input class="vertical-tabs-active-tab" type="hidden" value="account" name="tabs__active_tab">
I need JavaScript that will change the value of "account" to "yolo...
Biggs asked 5/11, 2013 at 20:53
1
Solved
I'm trying to use
onmouseover="document.getElementsByClassName().style.background='color'"
to change the color of all divs with a given classname to another color when hovering over anot...
Expectancy asked 20/9, 2013 at 22:55
1 Next >
© 2022 - 2024 — McMap. All rights reserved.