クリック時に.menu divを切り替えたいと思います。これは私が得たところであり、なぜJavaScriptが全く働いていないのか困惑しています。既に試してみました。メニュークリック時に切り替えます
大変助かります。
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
ありがとう、私はcodepenそれらを自動的に追加すると思った。ペンは今働いていますが、残念ながら、私はすでにjQueryを追加していた私の元のコードではやりません。 – halp