我有两个剧本
$(".MakeBid").on('click', function(e) {
e.preventDefault();
if ($('#pop_up').length) {$('#pop_up').html("").height('auto').width('auto').offset({left:0,top:0});}
var strSrc = 'index.asp?id=' + $(this).attr('id');
$.get(strSrc, function(data) {
if ($('#pop_up').length) {
$('<iframe src="' + strSrc + '"/>').appendTo('#pop_up');
$('#pop_up').show(function() {
$('#pop_up').height(150).width(800);
$('#pop_up').offset({top:e.pageY,left:e.pageX});
$('#pop_up').on( "mouseleave", function() {
if ($('#pop_up').length) {
$('#pop_up').html("").height('auto').width('auto').offset({left:0,top:0});
$('#pop_up').hide();
}
$('#pop_up').unbind();
});
$('.authorize-close').click(function(e){
e.preventDefault();
if ($('#pop_up').length) {
$('#pop_up').html("");
$('#pop_up').hide();
}
});
});
}
});
$(".MakeBid").unbind('click');
}); 和
$(".Login").on('click', function(e) {
e.preventDefault();
if ($('#pop_up').length) {$('#pop_up').html("").height('auto').width('auto').offset({left:0,top:0});} //restore div position and offset
var strSrc = 'index.asp?id=' + $(this).attr('id');
$.get(strSrc, function(data) {
if ($('#pop_up').length) {
$('<iframe src="' + strSrc + '"/>').appendTo('#pop_up');
$('#pop_up').show(function() {
$('#pop_up').height(150).width(800); //set div size
$('#pop_up').offset({top:e.pageY,left:e.pageX}); // set div offset
$('.authorize-close').click(function(e){ //on close button press
e.preventDefault();
if ($('#pop_up').length) {
$('#pop_up').html(""); //empty div
$('#pop_up').hide(); // hide div
}
});
});
}
});
$(".Login").unbind('click');
}); 因此,当我单击.MakeBid、$('#pop_up').on( "mouseleave",激活和关闭后的#pop_up,然后单击.Login $('#pop_up').on( "mouseleave",仍在工作。
怎么解开这个?
发布于 2015-09-30 08:56:57
您必须修改$('#pop_up').unbind();改为$('#pop_up').off("mouseleave");类似于下面的代码
$('#pop_up').on( "mouseleave", function() {
if ($('#pop_up').length) {
$('#pop_up').html("").height('auto').width('auto').offset({left:0,top:0});
$('#pop_up').hide();
}
$('#pop_up').off("mouseleave");
});
https://stackoverflow.com/questions/32861755
复制相似问题