我有一個div,我試圖將其類從一個切換到另一個。我只能切換一次,但不會返回原始類。我四處尋找可能的答案並查看了傳播函數,但我不確定這是否正確使用?jQuery toggleClass只能切換一次
<body>
<div id="wrapBreather">
<div id="counter" class="cInact">
<!--<canvas id="timerAnimation"></canvas>-->
</div>
</div>
<br />
<button id="startStopCount" class="HomeButton" >Start</button>
<script>
$(startStopCount).click(function(e){
e.stopPropagation();
$('.cInact').toggleClass('cDown cInact');
});
$('html').click(function() {
$('#counter').removeClass('cDown');
});
</script>
</body>
' $('#startStopCount')'錯字。 –