[英]Javascript pop up hide when click outside and show if links are clicked
need help.. this is my fiddle . 需要帮助..这是我的小提琴 。
it shows a pop up on first load.. 它会在第一次加载时显示一个弹出窗口。
the problem is when i click on the pop up it hides..how do i prevent this.. also when i click on a link it should show the pop up again and when i click outside of the pop up it will hide.. 问题是当我单击弹出窗口时它会隐藏..我该如何防止..也当我单击链接时,它应该再次显示弹出窗口,而当我单击弹出窗口之外时它将隐藏。
Script 脚本
$(document).ready( function() {
// When site loaded, load the Popupbox First
loadPopupBox();
$("#popupBoxClose").click( function () {
alert('hello');
unloadPopupBox();
});
$("#popup_box").click( function () {
e.stopPropagation();
});
$('#global_wrapper').click( function() {
unloadPopupBox();
});
$('.secure').click( function() {
loadPopupBox();
});
});
function unloadPopupBox() { // TO Unload the Popupbox
$('#popup_box').fadeOut("slow");
$("#container").css({ // this is just for style
"opacity": "1"
});
}
function loadPopupBox() { // To Load the Popupbox
$('#popup_box').show();
$("#container").css({ // this is just for style
"opacity": "0.3"
});
}
You aren't passing the event to the click handler, try updating this event handler, note the e passed as a parameter to the function: 您没有将事件传递给点击处理程序,请尝试更新此事件处理程序,注意将e作为参数传递给函数:
$("#popup_box").click( function (e) {
e.stopPropagation();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.