Search code examples
jquerycolorbox

How to trigger Jquery colorbox close button and close on overlay event


I want to trigger Colorbox event on clicking Close button and overlay close but it's not working:

$('#cboxClose').on('click', function() {
alert("Click button");
});

$("cboxOverlay").on('click', function() {
alert("Click overlay");
});

Solution

  • Use colorbox onClosed callback. See documentation: http://www.jacklmoore.com/colorbox/

    $(".popuplink").colorbox({
    
                    href: popupurl,
    
                    close: "Close",
    
                    overlayClose: true,
    
                    onComplete: function () {
    
                        alert("Completed");
    
                    },
                    onClosed: function () {
    
                        alert("Closed");
    
                    }
    
                });