jQueryのtoggleClass
に問題があります。toggleClassはクラスを変更しません
$(".guzik").click(function() {
$("#third").toggleClass('.pillar-animation-two');
});
function test(){
document.getElementById('third').className('.pillar-animation-two');
}
.pillar {
width:50px;
height:10px;
background-color:red;
margin-top:5px;
}
.pillar:nth-child(1) {
margin-top:0;
}
.pillar-animation-one {
transform:rotate (10deg);
}
.pillar-animation-two {
transform:rotate (20deg);
width:10px;
height:10px;
background-color:red;
margin-top:5px;
}
.pillar-animation-three {
animation-name:three;
animation-duration:1s;
}
@keyframes three {
0%{transform:rotate(0deg);}
100%{transform:rotate(40deg);}
}
.button {
margin-top:10px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="hamburger">
<div class="pillar"></div>
<div class="pillar"></div>
<div class="pillar" id="third"></div>
</div>
<button class="button" type="button" onclick="test()"> Click me !</button>
私が間違って何をやっている:
ここでは、コードですか? addClass
も動作しないので、私は本当に混乱しています。私もJS関数を作ったが、まだ動作していない。
ここで私は間違いをしましたか?
はElementはclassName
メソッドを持っていない