手机菜单在iPhone上无法关闭

时间:2015-11-01 11:58:45

标签: javascript responsive-design safari mobile-safari

我告诉我the mobile menu on my page(可通过右上角的3个横条图标访问)在iPhone上无法关闭。我无法检查自己,因为我没有Apple设备(在线iPhone模拟器上确实可以使用)但我不知道为什么它可以在Android而不是iPhone上运行。

这是控制移动菜单的JS代码:

$( '#mobile_menu_icon' ).click(function() {
    if( $( '.mobile_header_menu' ).css( 'right' ) == '-280px' ) { 
        $( '.mobile_header_menu' ).animate( { right: '0' }, open_delay, 'easeInOutExpo' );  
        $( '#wrap' ).animate({ right: '280px' }, open_delay, 'easeInOutExpo' );
        $( 'body' ).addClass( 'overflow_hidden' );
    }
    else { 
        $( '.mobile_header_menu' ).animate({ right: '-280px' }, close_delay, 'easeInOutExpo' );
        $( '#wrap' ).animate({ right: '0' }, close_delay, 'easeInOutExpo' );    
        $( 'body' ).removeClass( 'overflow_hidden' );
    }
    return false;
});
$( document, '.mobile_header_menu_close' ).click(function() {
    if( $( '.mobile_header_menu' ).css( 'right' ) == '0px' ) {
        $( '.mobile_header_menu' ).animate({ right: '-280px' }, close_delay, 'easeInOutExpo' );
        $( '#wrap' ).animate({ right: '0' }, close_delay, 'easeInOutExpo' );
        $( 'body' ).removeClass( 'overflow_hidden' );   
    }
});
$( '.mobile_header_menu_inner' ).click(function( event ) {
    event.stopPropagation();
});

2 个答案:

答案 0 :(得分:3)

我删除了以下部分并且它有效。不明白为什么它在iPhone上存在问题。

$( '.mobile_header_menu_inner' ).click(function( event ) {
    event.stopPropagation();
});

答案 1 :(得分:-1)

它运作得很好。

(在Xcode模拟器上测试iOS 9.1,9.0和8.4以及iPhone 6(iOS 9.1)和iPad Air(9.0))。

相关问题