How to change div background color on button click?

陌路散爱 提交于 2019-12-02 09:03:17

Be careful when you're using id on the html tags, because it makes an automatic var declaration using the id. So, you're overriding the btnReset function with the btnReset pointing to the <input>.

Solution 1: change the id="btnReset" or the function btnReset() name!

Solution 2: move your <script> to the end of the document (just before the </body> end tag, so your function overrides the automatic declarated var.

Additional info: http://www.2ality.com/2012/08/ids-are-global.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!