简体   繁体   中英

Mobile on click dropdown menu not working?

I want to create a dropdown menu for the mobile version of my site, but it doesn't seem to be working.

Basically when I click on the dropdown menu image, the dropdown menu should appear.

JSFiddle: https://jsfiddle.net/xfvjv184/

Included files:

     <link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jquerymobile/1.4.3/jquery.mobile.min.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquerymobile/1.4.3/jquery.mobile.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

HTML

<div class="mobile_dropdown_menu_icon">
    <img class="mobilemenuicon" src="resources/mobilemenuicon.png" />
</div>

<div class="mobile_dropdown_menu">

</div>

CSS

    .mobile_dropdown_menu_icon {
        display:none;
    }

    .mobile_dropdown_menu {
        display:none;
    }

@media(max-device-width:500px) {

    .mobile_dropdown_menu_icon {
            display: block;
            float:right;
        }

    .mobilemenuicon {
            width:150px;
            height:150px;
            margin-top:10px;
            margin-right:20px;
        }

    .mobile_dropdown_menu {
            background-color: red;
            height:400px;
            width:100%;
        }

}

jQuery

$(document).ready(function(){

    $('.mobile_dropdown_menu_icon').on("click" function() {
        $('mobile_dropdown_menu').css("display", "block");

    });   
});

Any reason this is not working? I click the icon that should display the mobile_dropdown_menu but it does not work with this code.

This line:

$('mobile_dropdown_menu').css("display", "block");

...is missing a period in front of mobile_dropdown_menu .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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