Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
请帮我!我创建了一个简单的手风琴,当您单击页面上的任何位置时,我试图关闭它,手风琴内容除外。
请参阅 JSFiddle:jsfiddle.net/2DaR6/201/
jsfiddle.net/2DaR6/201/
只需检查单击的元素是否在手风琴中
$(document).click(function(e) { if (!$( "#acc" ).is(e.target) && !$( "#acc" ).has(e.target).length) { $('#acc').accordion('activate', -1); } });
http://jsfiddle.net/2DaR6/202/