Got a website on squarespace which unfortunately is somewhat limited when it comes to adding code to buttons. An onlick would be ideal and I can add it via javascript HOWEVER the damn div ID changes each time the page is generated.
I need to somehow use js to search the page, find the button which has particular text in it and then I can use document.getElementById("ETC").onclick to perform what I need.
Question
Axel
Hi all,
Got a website on squarespace which unfortunately is somewhat limited when it comes to adding code to buttons. An onlick would be ideal and I can add it via javascript HOWEVER the damn div ID changes each time the page is generated.
I need to somehow use js to search the page, find the button which has particular text in it and then I can use document.getElementById("ETC").onclick to perform what I need.
My head hurts just thinking about this.
Any clues?
Link to comment
https://www.neowin.net/forum/topic/1273248-javascript-add-onclick-event-to-button-which-has-random-id/Share on other sites
3 answers to this question
Recommended Posts