Home>
I've learned how to add a class name to a div within a specific div class here
If a specific class name is on the same page as shown below
Is there a way to add it to a div class within another div class?
As an image, only when the class name "box1" div is in the same page
I want to add box2_del to the class name "box2_in".
(Added for htmlPage1, not added for htmlPage2)
var box = document.getElementsByClassName ('box1');
var boxin = box.querySelector (". box2_in");
boxin.classList.add ('box2_del');
-
Answer # 1
Related articles
- javascript - when an element with a specific class name is clicked, give an arbitrary class
- javascript - how to get the closest distance from a specific part among multiple elements with jquery
- javascript - [vuejs] in v-for, i added a specific element () at a specific number of times, but it is surrounded by tags and it
- javascript - i want to replace a class component with a function component
- javascript - is there a way to keep information that cannot be disclosed to the outside, such as access keys, on the front end s
- javascript - i want to use a value initialized in one class in another unrelated class with no arguments
- javascript - i want to hide only one specific column of a dynamically created table
- javascript - i want to apply a method only to a specific element for the element acquired by queryselecterall
- when there are many , css "display: none;" or javascript "append"?
- ruby on rails - how to test that a specific element has a class name using rspec/capybara
- javascript - jquery i want to select a specific element
- python 3x - python3: if there is a specific character string in the file, i want to divide the process and execute it only once
- javascript - switch layout (css) with or without specific child elements
- javascript - is there a way to check if the string is escaped with the chrome developer tool?
- javascript - it is not displayed if there are multiple
- javascript - i want to implement exception handling for a specific key when looping an object
- javascript - when i try to insert an array string as a class, it becomes undefined
- javascript - [web] please tell us how to automatically link all of the specific keywords in the text, or about global match
- javascript - in the parent component, i want to assign a class only to the specified property
- class name is not read when reading javascript from external file
Related questions
- javascript : How to get the size of the browser window using js or python and transfer this size to the css file?
- javascript : How to change the style file in index when clicking on the slider?
- javascript : Clear textarea on js
- javascript : Distance between menu items
- javascript : How to display part of an image on a website
- javascript : Two-column dropdown menu
- javascript : How do I make a regular div block work like input range?
- javascript : Encoding consisting of /letters and numbers
- javascript : Display the 1st column of the dropdown menu [duplicate]
- javascript : Adjusting window.open () window height for different screens
getElementsByClassName is supposed to return multiple elements, so it returns something like an array called HTMLCollection.
[Document.getElementsByClassName ()-Web API | MDN]
https://developer.mozilla.org/en/docs/Web/API/Document/getElementsByClassName
[Difference between the return value of getElementsByClassName and getElementById-Qiita]
https://qiita.com/rindarinda5/items/c26dc81fe8cd98992dc1