Я хочу переключить .menu div на клик. Это как далеко я получил, и я озадачен тем, почему javascript не работает вообще. Уже пробовал так много.Меню Toggle on click
Помощь очень ценится.
http://codepen.io/su1ts/pen/bZLwZN
HTML:
<header>
<button class="headerButton">
<ul class="hamburger">
<li></li>
<li></li>
<li></li>
</ul>
</button>
</header>
<div class="menu">a</div>
CSS:
header
:width 100%
:height 56px
:color #FFF
:position fixed
:font-size 20px
:z-index 9999
button.headerButton
:width 24px
:height 24px
:text-indent -30000px
:overflow hidden
:border none
:outline none
:cursor pointer
:position absolute
ul.hamburger
:margin-top 4px
:padding 0
li
:height 3px
:width 12px
:background blue
:list-style none
:margin auto
:margin-bottom 2px
:opacity 1
:border-radius 1px
:transition (.25s ease-in-out)
.menu
:width 100%
:height 100%
:background-color rgba(10,10,10,0.95)
:color white
:position fixed
:display none
:z-index 14
JS:
$(document).ready(function() {
$('button.headerButton').click(function() {
$('.menu').toggle();
});
});
Вы не добавили jquery в свой код. Ошибка консоли. Исправьте это, а затем посмотрите, что произойдет. – ADyson
Как упоминал @ADyson, вы не указали ссылку jQuery в кодексе. Вот рабочий код - http://codepen.io/anon/pen/EyQgWQ – Pugazh
Спасибо, я подумал, что косепен добавляет их автоматически. Теперь перо работает, к сожалению, это не делает трюк в моем исходном коде, где я уже добавил jQuery. – halp