Skip to content
Advertisement

After clicking button, alert is not showing up

I am doing a project on paper-rock-scissor that has UI. So, I have four buttons, Start game, rock, paper and scissor. I want if I click on the Start game button, an alert (“Please choose rock, paper, or scissor”) will pop-up. Right now if I click on the Start game. There’s nothing happening. I have no idea why? Below are my code :

——– HTML code ———

JavaScript

——– Javascript ———-

JavaScript

Advertisement

Answer

In your code, startGame is returning null

Method 1

In your html code, call javascript code at the end, before closing <body> tag

JavaScript

Method 2

Add the defer attribute to your script tag

JavaScript

You can look into this question for more information

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement