我最近使用了this来进行画布外导航。如果你在他们的演示中看到,他们所做的是,如果我们想要关闭侧边栏,就必须在正文中的任何地方单击,并且侧边栏中的一个类已经被删除以滑出侧边栏。
我想要的是同样的效果是要做的,而在单击关闭按钮内的侧边栏,侧栏必须滑出。如何做到这一点?
这是他们用来删除类的代码。
var container = document.getElementById( 'st-container' ),
buttons = Array.prototype.slice.call( document.querySelectorAll( '#st-trigger-effects > button' ) ),
// event type (if mobile use touch events)
eventtype = mobilecheck() ? 'touchstart' : 'click',
resetMenu = function() {
classie.remove( container, 'st-menu-open' );
},
bodyClickFn = function(evt) {
if( !hasParentClass( evt.target, 'st-menu' ) ) {
resetMenu();
document.removeEventListener( eventtype, bodyClickFn );
}
};谢谢
发布于 2013-10-07 17:25:43
我想你对jquery很熟悉:
$(document).ready(function () {
$('#Your-close button-id').on('click', function () {
$(this).removeClass('st-menu-open');
});
});https://stackoverflow.com/questions/19219402
复制相似问题