javascriptで、buttonにeventを登録したいです。サイトを参考にして以下のコードを書いたのですが、動きません。どこが間違っていますか?
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link type="text/css" rel="stylesheet" href="/css/global.css" /> <title>Preview</title> </head> <body> <div class="button"> <input type="button" value="test" id="a" /> </div> <script><!--リスナー登録--> function a(){alert("test");} var allplay = document.getElementById("allplay"); allplay.addEventListener("click", a, false); </script> </body> </html>
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/01/31 03:51
2016/01/31 08:34