I am working on a view where it lists my articles. I need to remove CSS classes from each of these articles in this page. My code is working on the first item but it is not looping on the other items existing on the page.
Here is my code:
Drupal.behaviors.cardload = {
attach: function (context, settings) {
const $el = context.querySelector(".user-card");
const $content = context.querySelector(".card__content");
// Loading finished
setTimeout(() => {
$el.classList.remove('skeleton');
$el
.querySelectorAll(".skeleton")
.forEach(el => el.classList.remove("skeleton"));
$el
.querySelectorAll(".hide-text")
.forEach(el => el.classList.remove("hide-text"));
$content.classList.remove('skeleton');
$content
.querySelectorAll(".hide-text-title")
.forEach(content => content.classList.remove("hide-text-title"));
$content
.querySelectorAll(".hide-text")
.forEach(content => content.classList.remove("hide-text"));
$content
.querySelectorAll(".hide-text-body")
.forEach(content => content.classList.remove("hide-text-body"));
$content
.querySelectorAll(".hide-text-author")
.forEach(content => content.classList.remove("hide-text-author"));
}, 1000);
}
}
Can someone please help me how to add a for loop or something that fetches all the items in my view and remove all the classes from all the items after 1000 milliseconds?
Thank you