Reputation: 33
I want to make a menu for my website. It's inside div with display: none
set.
I want my menu to show as clicking on the image. I'm new at JS, so maybe I'm doing it entirely wrong. Are there any right ways to do this?
$(document).ready(function() {
$("menuimg").click(function() {
$("menu").toggleClass("vis");
});
});
#menu {
position: fixed;
display: none;
}
.vis {
display: block;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<header id="mnu">
<div id="menubackground">
<img id="menuimg" src="Logo.png" alt="" /></div>
</header>
<header id="menu">
<div id="hid">
<img src="Logowhite.png" alt="" />
</div>
</header>
Upvotes: 0
Views: 63
Reputation: 36703
You forgot the #
for using id as a selector
$(document).ready(function(){
$("#menuimg").click(function(){
$("#menu").toggleClass("vis");
});
});
Upvotes: 2