这篇文章主要介绍“jQuery怎么实现点击其他地方时菜单消失”,在日常操作中,相信很多人在jQuery怎么实现点击其他地方时菜单消失问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”jQuery怎么实现点击其他地方时菜单消失”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
具体代码如下:
<script type="text/javascript">
function stopPropagation(e) {
if (e.stopPropagation)
e.stopPropagation();//停止冒泡 非ie
else
e.cancelBubble = true;//停止冒泡 ie
}
$(document).bind('click',function(){
$('#test').css('display','none');
});
$('#test').bind('click',function(e){
//写要执行的内容....