I'm working with html and in this job I would like get one help from you
Look the following question
I have this div
<div class="my-class">
<h1 class="title">Test 1</h1>
</div>
<div class="my-class">
<h1 class="title">Test 2</h1>
</div>
<div class="my-class">
<h1 class="title">Test 3</h1>
</div>
<div class="my-class">
<h1 class="title">Test 4</h1>
</div>
I would to do one loop to get the text from h1 to hide if text is Test 1
I'm trying like this:
var htmlCollection = document.getElementsByClassName('my-class')
console.log(htmlCollection);
Array.prototype.slice.call(htmlCollection).forEach(element => {
console.log(element);
});
or
Like this:
var htmlCollection = document.getElementsByClassName('bs-media-item-card-array-1')
var BoxArray = Array.from(htmlCollection);
console.log(BoxArray);
Or
var htmlCollection = document.getElementsByClassName('bs-media-item-card-array-1')
for(index of htmlCollection){
console.log(index);
}
Or
for(index in htmlCollection){
if(index <= htmlCollection.length) {
console.log(htmlCollection[index]);
}
}
The return from
var htmlCollection = document.getElementsByClassName('my-class')
Is this
HTMLCollection []
0: div.my-class
1: div.my-class
2: div.my-class
3: div.my-class
length: 4
[[Prototype]]: HTMLCollection
UPDATE
Sometimes I tried to use like this, too
<div class="my-class">
<a class="my-subclass">
<h1 class="title">Test 2</h1>
</a>
</div>
<div class="my-class">
<a class="my-subclass">
<h1 class="title">Test 3</h1>
</a>
</div>
Thanks for help me