Skip to content
Advertisement

How to get the text from certain class name if other sibling class exists?

I’ve tried to get the text from class="eventAwayMinute">57 in every matchEvent class (Parent tag) If a matchEvent class contains class="eventIcon eventIcon_1":

JavaScript

I tried

JavaScript

and it dose not work.

I tried also

JavaScript

But it returns all minutes that exist in every matchEvent (There is several matchEvent classes in html code).

Advertisement

Answer

You can use the :has() CSS Selector to check if matchEvent has an eventIcon eventIcon_1 class, and than print the eventAwayMinute class:

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement