How to close a jQuery fancybox from button click

You can use inline call

<input type="button" onclick="$.fancybox.close()" value="CloseFB" />

Or either you can use function called

<script>
function closeFB() {
    // Before closing you can do other stuff, like page reloading
    $("#destination_div").load("?v=staff #source_div_with_content"); 
    // After all you can close FB
    $.fancybox.close(); 
}
</script>

<input type="button" onclick="closeFB()" value="CloseFB" />

Call function in onClickevent


call to $.fancybox.close();

also look on this answers in the post

According to http://fancybox.net/faq

  1. How can I close FancyBox from other element? ?

Just call $.fn.fancybox.close() on your onClick event

So you should just be able to add in the fn.


I had to use parent.jQuery.fancybox.close() with my Drupal site to get this to work properly.