I'm working on a page that displays a map via jQuery, and I have a div layered in front of the map, with an x in the corner to be used to close it. When I disable the map, clicking the x closes the div (via jQuery's fadeOut()
function), but when the map loads, the x does nothing.
Is there any way to enable the .click()
function on a layered div like this? Using a delegated event handler does not solve the problem.
$('#close_btn').click(function() {
$('#msg1').fadeOut('fast');
});
or
$(document).on('click','#close_btn',function() {
$('#msg1').fadeOut('fast');
});
<div class="message" id="msg1">
<div class="inner">
<span class="title">Some stuff!</span>
<span class="tip_msg">Some other stuff.</span>
<span id="close_btn"><i class="fa fa-times" aria-hidden="true"></i></span>
</div>
</div>