795 votes
0 answers
javascript - Script not removing class from targeted element
Solution:
It seems like your guess is right on that the installed bundle application doesn't yet load the elements you're trying to call a function on, hence receiving an undefined console log. Try using the setTimeout when defining the function, like this:
setTimeout(function removethat() {
console.log(removethisone[0]);
let targetedelement = removethisone[0];
console.log(targetedelement);
targetedelement.classList.remove('kaching-bundles__bar--variants-hidden');
},1000)
Let me know if this could help. This way you're delaying the function and giving the website enough time to load the bundle widget, so you will be able to target the widget elements.
Undefined asked
Source
Didn't find the answer?
Our community is visited by hundreds of Shopify development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.