#How can I set css selector that checks for start of name of a class?

1 messages · Page 1 of 1 (latest)

unreal tide
#

for example "styles_verificationIcon___X7KO".
I want to find element by class that starts with "styles_verificationIcon".
This does not work: document.querySelector("[class^=styles_verificationIcon]");

arctic totem
#

Hi @unreal tide have you tried adding quotes around styles_verificationIcon? There might be an issue with omitting quotes when class is not alphanumeric

unreal tide
#

I have tried ' ', " " does not work

arctic totem
#

The selector looks ok to me, have you tried testing it in chrome devtools?

unreal tide
#

I am trying to get

unreal tide
arctic totem
#

Ah yes, this is because the class attribute doesn't actually start with styles_verificationIcon, there are other classes before

unreal tide
#

what can I do instead?

arctic totem
#

I would try using div[class*="styles_verificationIcon"]

#

this will select any element where class contains styles_verificationIcon

unreal tide
#

thank you very much

#

it works flawless