JavaScript how to find a class that is constantly changing

43 Views Asked by At

Example: the class was Paragraph__P2Short--18r8zx8 styles__DateUpdated--7vi2vd kYkeUS after an hour it changed to Paragraph__P2Short--vgyzhi styles__DateUpdated--6ztczv fQPIAt. How do I find such classes?

I tried document.getElementsByClassName("") but the class is constantly changing, but the styles__DateUpdated does not change in the class

1

There are 1 best solutions below

0
boppy On BEST ANSWER

You might try a CSS selector with .querySelectorAll, like:

const elements = document.querySelectorAll('[class*="styles__DateUpdated--"]');

It will givve you all elements containing the string "styles__DateUpdated--" inside the class attribute. For sure you might have to go deeper to filter down to what you need...