0

I want to target a data-ref with a specific value and add an inline style="display:none;" to it.

How can this be achived? Can someone help me please?

This is how it looks:

<div data="{test-bubble}}" data-ref="bubbles[test-link.com/test]" class="bubbles" state="default">
</div>

I tried this but it does not work:

var bubbleremoval = document.querySelector('[data-ref="bubbles[test-link.com/test]"]')
bubbleremoval.style.display = "none";

5

1 Answer 1

1
"""Your code should work if you are applying to a single element since query selector returns one element but for several elements you could fetch by classname and loop through the elements and remove display for each"""
var bubbleremoval = document.getElementsByClassName('bubbles')
     for (let i = 0; i < bubbleremoval.length; i++) {
        bubbleremoval[i].style.display = "none";
     }
1
  • Thank you for responding! I found out that the problem was related to something else and not my code.
    – Jio
    Nov 25, 2022 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.