removeClass();将不适用于safari mobile

时间:2013-09-30 22:05:50

标签: jquery mobile safari

我需要帮助,我一直在努力让这个工作......:

btnMenu.on('click', function(e) {
    var $this = $(this);

    $this.addClass('selected');

    if(menu.is(':visible')) {
        alert('visible'); // This works
        $this.removeClass('selected'); // This doesnt work in safari mobile but works everywhere else.
    }

    menu.stop().slideToggle(500, 'easeInOutQuint');

    e.preventDefault();
});

谢谢

1 个答案:

答案 0 :(得分:0)

如何不首先添加“已选择”而是使用其他?

if(menu.is(':visible')) {
    alert('visible'); // This works
    $this.removeClass('selected'); // This doesnt work in safari mobile but works everywhere else.
} else {
    $this.addClass('selected');
}

甚至,根据您的代码;

if(!menu.is(':visible')) {
    $this.addClass('selected');
}