1

Demo: http://admin.bigblackbag.net/web/mobile_content.asp?WebsiteID=15175&forcemobile=1

Works perfectly on iPhone.. but seems to crash on native Android browser.. it crashes when you try to use the navigation menu and doesn't look adjust properly.. Any ideas? Pretty please!? Been stumped for weeks..

$(function () {
var menuStatus;
// Show Menu
$("a.showMenu").click(function () {
    if (menuStatus != true) {
        $("#page").animate({
            marginLeft: "85%",
        }, 300, function () {
            menuStatus = true
        });
        $("#page").css("position","fixed");
        $("#page").addClass("shadow");            
        $("#menu").animate({opacity: "1"}, 300);
        return false;
    } else {
        $("#page").animate({
            marginLeft: "0px",
        }, 300, function () {
            menuStatus = false
        });
        $("#page").css("position","absolute");
        $("#page").removeClass("shadow");
        $("#menu").animate({opacity: "0"}, 300);
        return false;
    }
}); 
 // Menu behaviour
$("#menu li a").click(function () {
    var p = $(this).parent();
    if ($(p).hasClass('active')) {
        $("#menu li").removeClass('active');
    } else {
        $("#menu li").removeClass('active');
        $(p).addClass('active');
    }
  });   
});
4

1 回答 1

0

尝试这个:

$(function () {
var menuStatus;
// Show Menu
$("a.showMenu").click(function (e) {
    if (menuStatus != true) {
        $("#page").animate({
            marginLeft: "85%",
        }, 300, function () {
            menuStatus = true
        }).css("position","fixed").addClass("shadow");            
        $("#menu").animate({opacity: "1"}, 300);
    } else {
        $("#page").animate({
            marginLeft: "0px",
        }, 300, function () {
            menuStatus = false
        }).css("position","absolute").removeClass("shadow");
        $("#menu").animate({opacity: "0"}, 300);
    }
    e.preventDefault();
}); 
 // Menu behaviour
$("#menu li a").click(function () {
    $("#menu li").removeClass('active');
    $(this).parent().addClass('active');
  });   
});
于 2013-02-12T17:05:55.340 回答