我有一个从左侧滑入的侧窗格,使用get()动态添加内容。我希望窗格外的所有点击都能通过触发某个功能来关闭它。根据我阅读的其他问题,我提出了以下代码。jQuery on()和stopPropagation()
$('html').click(function() {
if (side_showing) {
close_side();
}
});
$(document).on("click", "#side", function(event) {
event.stopPropagation();
});
我似乎无法使它工作。我知道on()
函数正在被触发,但似乎不是event.stopPropagation
。有小费吗?
你是否真的意识到'stopPropagation();'的含义?看看http://www.javascripter.net/faq/eventbubbling.htm#demo – 2012-08-11 01:59:40