Modifying button links with Javascript

Hello all, trying to modify button links based on parameters in the URL when a user lands on the site. I’m able to get parameters out in a neat script as described here: Pass URL Parameters to Button - #11 by Andrea_Montagnani

I have many buttons that need to be modified, and I would like to pass link definition to all buttons with a certain class. So, I don-t want to access a button via it’s id, but rather it’s class name. This means in my script I’m using “getElementsByClassName”, which produces a nodelist (an array-like thing). All good so far…

My problem: I cannot access any of the (button) elements in this nodelist to perform operations on the href. When I look at the nodelist, it has several (button) elements… but when I try to use something like NodeList.item(0)), there’s an error because for some reason the length of NodeList is 0 (NodeList.length = 0).

Anyone able to perform JS operations on a nodelist in Webflow? How?

Hi @Shaolin69, not sure about nodelist, but I would usually just loop the array and apply classes as needed. You should share the preview link if you can just so we can help troubleshoot.