Issue
I have a specific wrapper element where the class has a specific name included, alongside with a random id. Example wp-rgtayfu-fxyjzw-wrapper
. The class will always contain the wrapper
substring. There is only one element in the document where the class contains wrapper
.
How can I find it? (Or how can I query an element by class, using only a substring part of it?)
Solution
you can use this CSS Selector.
[attribute*="value"]
It will select element with a class attribute that contains the specified "value":
const targetElement = document.querySelector('[class*="wrapper"]')
Answered By - Akashch47
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.