Please help me with this problem in HTML,JS
I am new to web developing. just learnt html, css, js. decided to make a small quiz but it is not working. please help. this is html code:- <!DOCTYPE html> <html> <head> <title>Short quiz</title> <script type="text/javascript" src="script.js"></script> </head> <body> <p>What is Batman's real name?</p> <form> <input type="radio" name = "bw" id = "bw">Bruce Wayne<br> <input type="radio" name = "bw" id = "zr">Zack Ryder<br> <input type = "radio" name = "bw" id = "jg">Jim Gordon<br> <input type = "button" name = "submit" id = "sb" value = "Submit"><br> </form> </body> </html> and here is js code:- if(document.getElementById("sb").onclick){ if(document.getElementById("bw").checked){ alert("Correct answer")} else if(document.getElementById("zr'").checked){ alert("Wrong answer")} else if(document.getElementById("jg").checked){ alert("Wrong answer")} } but when i open the webpage, select a option and submit not alert pops. pls help. both html and js are in same folder.