这段代码之后,按钮的css还是改了。当按钮未激活时,我想回到正常的 css。
JavaScript
$('#btn1').on('click', function() {
$("#btn1").css({color:'red'})
$('#story').fadeToggle(400);
});
HTML
<div id="story" style="display:none;">
My div
</div>
<input id="btn1" type="button" value="Click Here" />
最佳答案
为什么不给那个按钮添加类?
$('#btn1').on('click', function(){
$(this).toggleClass('active'); // If has class, removes it, otherwise, it adds that class
$('#story').fadeToggle(400);
});
关于javascript - 更改为默认样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24058846/