Solved

Class Attribute Selection

  • 8 March 2023
  • 1 reply
  • 86 views

Badge +1

Hi! 

I’m having trouble defining a event that tracks clicks on div elements with classes containing a specific substring. Let’s say that substring is “keyword”, so my selector would be div[class*="keyword"] and I would expect click events to be tracked on both <div class=”keyword-1234” /> and <div class=”keyword-abcd” /> .

 

When I view my webpage and query that selector using the browser console, both of those element match correctly; however, I’m not getting any data when I define my event like this. Is there a reason this approach isn’t working?

 

Thanks!

 

icon

Best answer by Ethan 9 March 2023, 02:02

View original

1 reply

Badge +1

I was able to solve this after reading this answer! Using div.keyword-* worked for me

Reply