简体   繁体   English

移动设备菜单jQuery onload问题?

[英]Menu for mobile devices jQuery onload problems?

I have a menu for mobile devices, and I need to be onload as hidden not as pulled, anybody can help me? 我有一个用于移动设备的菜单,我需要隐藏而不是被拉动,有人可以帮助我吗? I use jquery/1.7.2 jquery.min.js 我使用jquery / 1.7.2 jquery.min.js

    $(function() {

        var pull        = $('#pull');
            menu        = $('nav ul');
            menuHeight  = menu.height();

        $(pull).on('click', function(e) {
            e.preventDefault();
            menu.slideToggle(); 
        });

        $(window).resize(function(){
            var w = $(window).width();
            if(w > 300 && menu.is(':hidden')) {
                menu.removeAttr('style');
            }
        });
    });


    <a href="#" id="pull">meniu</a>                     
<nav class="clearfix1">
    <ul class="clearfix1">
            <li><a href="/categorie-produs/femei/"><strong>Femei</strong></a></li>
            <li><a href="/categorie-produs/barbati/"><strong>Barbati</strong></a></li>
            <li><a href="/categorie-produs/branduri/"><strong>Branduri</strong></a></li>
            <li><a href="/categorie-produs/contact/"><strong>Contact</strong></a></li>
    </ul>
</nav>

and demo of my script http://jsfiddle.net/ss1z6awv/ 和脚本演示http://jsfiddle.net/ss1z6awv/

you can hide the ul element on load. 您可以在加载时隐藏ul元素。 like this below 像下面这样

        <ul class="clearfix1" style="display:none;">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM