could you please tell me why click event is not firing when I am taking selector
in object
;
here is my code
https://jsbin.com/seregezahe/1/edit?html,js,output
(function(){
$(function(){
var config ={
btn:$('#btn'),
hello:$('.hello'),
bodyClickEvent: $("body"),
overlayClick: $('.overlay'),
closeBtnSelector: '#closeBtn',
};
config.btn.click(function(){
$('#container').append($('#overlay').html())
$('.popupdata').html('<div class="hello">xxxx</div><a href="javascript:void(0)" id="closeBtn" >X Close</a></div>');
})
config.bodyClickEvent.on("click", config.closeBtnSelector, function () {
//why it is not working
config.overlayClick.fadeOut(500);
config.overlayClick.remove();
// below code is working fine
//$('.overlay').fadeOut(500);
//$('.overlay').remove();
});
})
})()
why these two line are not working
config.overlayClick.fadeOut(500);
config.overlayClick.remove();
when I run my code it show a button
when I click on button some html is show
with close button text .When I click close button it is not fadeout
my html and remove.