当您单击外部手风琴时如何制作它? [英] How to make a closing accordion when you click outside of it?
本文介绍了当您单击外部手风琴时如何制作它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请帮助我! 我创建了一个简单的手风琴,当您单击页面上的任意位置(手风琴内容除外)时,我试图将其关闭.
Please help me! I create a simple accordion and I'm trying to make it close when you click anywhere on the page, except for accordions content.
请参见JSFiddle:jsfiddle.net/2DaR6/201/
See JSFiddle: jsfiddle.net/2DaR6/201/
推荐答案
只需检查一下单击的元素是否在手风琴中即可
Just check to see if the clicked element was in the accordian or not
$(document).click(function(e) {
if (!$( "#acc" ).is(e.target) && !$( "#acc" ).has(e.target).length) {
$('#acc').accordion('activate', -1);
}
});
http://jsfiddle.net/2DaR6/202/
这篇关于当您单击外部手风琴时如何制作它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文