Im opening a div on click of another div.Below code seems to be working only for the first time.
It works when page refreshes. Close event always get called but click event does not fire.
$('.redirection-list .redirection a').on('click', clickevent);
function clickevent() {
$(this).attr("href", "#myCurrentDiv");
$('.redirection-list li').removeAttr('id');
$(this).closest('li').attr("id", "myCurrentDiv");
$('.redirection-list .redirection').removeClass('active');
$(this).closest('li').addClass('active');
$('.block-list').removeClass('col-sm-12');
$('.block-list').addClass('col-sm-6');
$('.redirection-edit').addClass('open');
$('.redirection-status span:nth-of-type(2n)').hide();
$('.redirection-status span:nth-of-type(n)').css('border-radius', '50px');
if ($(window).width() <= 768) {
$('body').addClass('mobile-device');
}
else {
$('body').removeClass('mobile-device');
}
$('.redirection-edit').insertAfter(this);
$('.redirection-edit').fadeIn(700);
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
if ($(target).closest('.block-list').hasClass('search-list')) {
$('html, body').animate({
scrollTop: target.offset().top - 185
}, 500);
return false;
}
else {
$('html, body').animate({
scrollTop: target.offset().top - 112
}, 500);
return false;
}
}
}
}
$('.redirection-edit .close').click(function () {
$('.redirection-edit').removeClass('open');
$('.redirection-edit').fadeOut(500);
$('.redirection-list .redirection').removeClass('active');
$('.block-list').removeClass('col-sm-6');
$('.block-list').addClass('col-sm-12');
$('.redirection-status span:nth-of-type(2n)').show();
$('.redirection-status span:nth-of-type(n)').css('border-radius', '50px 0px 0px 50px');
$('.redirection-status span:nth-of-type(2n)').css('border-radius', '0px 50px 50px 0px');
$('.redirection-list .redirection a').bind('click',clickevent)
});