JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://fancyapps.com/fancybox/source/jquery.fancybox.js"></script>
<link rel="stylesheet" href="http://fancyapps.com/fancybox/source/jquery.fancybox.css">
<div id="a1">
<p>Click on the box</p>
<div class="r"></div>
</div>
CSS
#a1{width:320px;height:100px;}
#a1 > div{
float:left;
width:300px;
height:100px
}
.r{background:red}
JavaScript
$(document).ready(function()
{
$('#a1').fancybox({
afterClose: function()
{
console.log('closed :( ');
}
}).click();// or .trigger('click');
});