How to change div background color on button click?

后端 未结 1 1204

I can change the background color Red, Blue, as well as Green, but when I click the Reset button I get an error in Chrome(browser):

btnReset is not a function,

1条回答
  •  没有蜡笔的小新
    2021-01-28 14:12

    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 .

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

    Solution 2: move your

提交回复
热议问题