Skip to content

Instantly share code, notes, and snippets.

@cheenwe
Last active March 29, 2017 12:21
Show Gist options
  • Save cheenwe/7fb5d658845cdff7bae8a9d28d15e902 to your computer and use it in GitHub Desktop.
Save cheenwe/7fb5d658845cdff7bae8a9d28d15e902 to your computer and use it in GitHub Desktop.
判断移动端,控制导航的样式
    /**判断移动端,控制导航的样式**/
    if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE|RIM|Windows Phone|Nexus|Nokia/.test(navigator.userAgent))){
        if(window.location.href.indexOf("?mobile")<0){
            try{
                if(/Android|webOS|iPhone|iPod|BlackBerry|RIM|Windows Phone|Nexus|Nokia/i.test(navigator.userAgent)){
                    loadCSS("css/website/style.mobile.css");
                }else if(/iPad/i.test(navigator.userAgent)){
                    loadCSS("css/website/style.mobile.css");
                }else{
                }
            }catch(e){}
        }
    }else{
        if(pageIndex == 1){
            $(".nav .menu-box .top-li:nth-child(2)").css("border-bottom","3px solid #53b983");
            $(".nav .menu-box .top-li:nth-child(2)>a>.text").css("color","#53b983");
        }else if(pageIndex == 2){
            $(".nav .menu-box .top-li:nth-child(3)").css("border-bottom","3px solid #f9af41");
            $(".nav .menu-box .top-li:nth-child(3)>a>.text").css("color","#f9af41");
        }else if(pageIndex == 3){
            $(".nav .menu-box .top-li:nth-child(1)").css("border-bottom","3px solid #1b75bb");
            $(".nav .menu-box .top-li:nth-child(1)>a>.text").css("color","#1b75bb");
        }else if(pageIndex == 4){
            $(".nav .menu-box .top-li:nth-child(4)").css("border-bottom","3px solid #53b983");
            $(".nav .menu-box .top-li:nth-child(4)>a>.text").css("color","#53b983");
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment