0

I am using the below code for a menu to apear on a mobile css site.

At the moment it is appearing straight away when the site is loaded and I'd rather it load only on request when it is used... Any help? - I know it's a quick solution but cannot seem to work this out, i've tried other forums and searched online and yet to hear a response.

<script type="text/javascript">
jQuery(document).ready(function($){

    /* prepend menu icon */
    $('#nav-wrap').prepend('<div id="menu-icon"><img id="logo" src="<?php echo site_url(); ?>/wp-content/themes/blue-and-grey/images/mobileimages/hme_btn.png" /></div>');

    /* toggle nav */
    $("#menu-icon").on("click", function(){
        $("#nav").slideToggle();
        $(this).toggleClass("active");
    });

});
</script>
4

2 回答 2

2

您可以添加一些简单的 CSS 来隐藏元素

CSS

#menu-icon{
   display: none;
}
于 2013-05-03T00:09:00.640 回答
0

Just call hide() on whatever element it is that you want hidden, e.g. $("#nav").hide(), somewhere after the prepend.

于 2013-05-03T00:08:33.623 回答