我得到一个".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)