I have a form system that is dynamically generated.
Below is the code that invokes the calendar.
<input id="btn1_0" type="button" value="☵" class="rsform-calendar-box btnCal rsform-calendar-button btn btn-default" onclick="RSFormPro.YUICalendar.showHideCalendar('cal1_0Container');">
Here is the div that appears when the button above is clicked. The button toggles the display:none style when clicked inside a div :
<div id="cal1_0Container" style="clear: both; position: absolute; z-index: 9987;" class="yui-calcontainer single"> Calendar Here </div>
I want to hide the calendar when someone clicks and outside the div.
I tried this JS but it will not work as it sets display:none to div. What am I doing wrong?
jQuery(document).click(function(event) { if ( !jQuery(event.target).hasClass('yui-calcontainer')) { jQuery(".yui-calcontainer").hide(); } });
source share