小编lee*_*ter的帖子

".addEventListener不是函数"为什么会出现此错误?

我得到一个".addEventListener不是函数"错误.我坚持这个:

var comment = document.getElementsByClassName("button");
function showComment() {
  var place = document.getElementById('textfield');
  var commentBox = document.createElement('textarea');
  place.appendChild(commentBox);
}
comment.addEventListener('click', showComment, false);
Run Code Online (Sandbox Code Playgroud)
<input type="button" class="button" value="1">
<input type="button" class="button" value="2">
<div id="textfield">
</div>
Run Code Online (Sandbox Code Playgroud)

html javascript

33
推荐指数
5
解决办法
13万
查看次数

标签 统计

html ×1

javascript ×1