【发布时间】:2021-10-27 21:50:52
【问题描述】:
我需要一个可以改变背景颜色的按钮,如果你点击它 2 次。 我怎么能做到这一点?,我只知道如何通过 1 次点击来做到这一点。 我的代码实际上是这样的:
<button onClick="document.body.style.backgroundColor ='#000';"> color </button>
【问题讨论】:
-
您的意思是当按钮被“双击”时,例如打开应用程序时或第二次单击时,无论多快?
-
不管多快
-
在这种情况下,接受 Spectric 答案。如果您不想分隔 JS 块,请使用:
-
成功了,很棒
标签: javascript html css button onclick