Search code examples
jquerycolorbox

closing jquery colorbox modal window when clicking specific button which exists in the content came from external link


I have a jquery colorbox application.In this application,When i click a link,a jquery colorbox modal box opens and it contents come from external link.There is a button inside of the content and i want to close colorbox window when i click that button.Is there any way to close colorbox modal window?There is colorbox's own closing button but i dont want to use that because my application needs a button in order to close it. I used $.fn.colorbox.close(); when click button but it didn't work. Thanks for advance...


Solution

  • Try attaching a jQuery live event to the button. Assuming you add a button with class closebutton to the color box content:

    $('#cboxContent .closebutton').live('click', function(){
     $.fn.colorbox.close();
    });