Select classes with javascript as apposed to ID tags (not working in webflow)

For some reason classes don’t seem to work in webflow when you try to select them like this instead of using IDs. For example:

var x = document.getElementsByClassName("myClass");

var x = document.querySelectorAll("myClass");

I need to animate something with gsap in webflow but access a ton of elements with the same class name and stagger them, however IDs only seem to work inside webflow.

Anyone have any idea why this is?


I’ve never come accross this issue - it certainly is possible to get elements by class name from Webflow sites in my experience.

If you can share the code you’re using or the site you’re trying to apply this to I might be able to help more.

Getting elements by class name or query selector all returns an array, where as getting an element by id will only return that single element. If you are getting an array you need to loop over it and apply whatever it is you are doing to each item in the array.