How do I target a button with JS to get an onclick event?
I've got a script that watches for buttons with a certain class, but the LS button links don't have a class (or ID) applied to them, so there's no direct way to target them. And they're not children of the class/id that's given to the button layer, so I'm not sure of a simple way to target those buttons.
You should add a specific class or ID to the button layer and then you can use this selector for example: #button-layer a
Other option is that, if you click to the links and attributes tab then you can add custom attributes for your button layer, for example an onclick event.
The ID and CLASS fields under Link & Attributes set those attributes of the previous child span on LS buttons...I tried playing around with things, and found that the ones labeled "On parent" actually set the attributes on the a - which was weird, but welcome to find, made it simple for doing what I needed as I could target using the rel attribute directly on the a element.
How do I target a button with JS to get an onclick event?
I've got a script that watches for buttons with a certain class, but the LS button links don't have a class (or ID) applied to them, so there's no direct way to target them. And they're not children of the class/id that's given to the button layer, so I'm not sure of a simple way to target those buttons.
Hello Joshua,
Thank you for getting in touch with us!
You should add a specific class or ID to the button layer and then you can use this selector for example:
#button-layer a
Other option is that, if you click to the links and attributes tab then you can add custom attributes for your button layer, for example an onclick event.
Best Regards,
Andrea | Kreatura Support Team
The ID and CLASS fields under Link & Attributes set those attributes of the previous child span on LS buttons...I tried playing around with things, and found that the ones labeled "On parent" actually set the attributes on the a - which was weird, but welcome to find, made it simple for doing what I needed as I could target using the rel attribute directly on the a element.
Thank you.
You are welcome!
Best Regards,
Andrea | Kreatura Support Team