Tagging Modals / Popups

Bronze Contributor
Bronze Contributor


On Screwfix.com we have a popup that shows when a customer clicks the delivery or Click and collect buttons. 


When an add to basket button is clicked JS kicks in and shows the pop up for that product, I want to be able to tag the buttons within this modal, however, when i create a jQuery onHandler it does not fire when that class is clicked.... is this because the markup is not in the DOM until the div is clicked and JS shows the modal?


How can I tag the different elements?


Many Thanks



Tagging Modals / Popups

Employee Emeritus

Hello @jhooper. Great question. Perhaps this post can help? 


Let me know! 


Remember to give me a kudo if you like my post! Accepting my post as a solution is even better! Also remember that search is your friend.

Tagging Modals / Popups

Gold Contributor
Gold Contributor
Hello @jhooper

I would recommend to go ahead with below JS code to able to tag the required buttons within your modal. Sometime your code will execute before DOM is ready.

addEvent(window, 'load', function(e) {
var input = document.body;
addEvent(input, 'mousedown', function(e) {
var target = window.event ? window.event.srcElement : e ? e.target : null;
if (target.parentNode.id === 'abc') {

Hope it helps! Kindly let me know if you need any clarifications on this. Thanks!