Button不会链接到Javascript

时间:2015-02-25 16:50:33

标签: java javascript button

<div class ="form-group">
    <div class ="form-group">
         <div class="col-xs-8 col-xs-offset-4">
             <input type = "button" value="Play Game" class="btn btn-primary" id="play">
         </div>
    </div>

JavaScript代码

play=document.getElementById("btn-primary");`
play.addEventListener("click", handleAdd, false);

1 个答案:

答案 0 :(得分:3)

id是'play',而不是'btn-primary'