首页 > 其他 > 详细

回复评论写法

时间:2016-06-22 21:43:51      阅读:207      评论:0      收藏:0      [点我收藏+]

html部分:

<body>
<h1>添加评论</h1>
<ul id="comments">
<li>你好</li>
<li>hello</li>
</ul>
<textarea id="textarea" rows="8" cols="40"></textarea>
<br>
<button id="submit">提交评论</button>
<script src="./js/添加评论.js"></script>
</body>

JS部分:
var button = document.getElementById(‘submit‘);
var textarea = document.getElementById(‘textarea‘);
var ul = document.getElementById(‘comments‘);

button.onclick = function() {
var commentText = textarea.value;
appendComment(commentText);
clearTextarea();
};

function appendComment(text) {
var newComment = document.createElement(‘li‘);
newComment.innerHTML = text;
ul.appendChild(newComment);
}

function clearTextarea() {
textarea.value = ‘‘;
}

回复评论写法

原文:http://www.cnblogs.com/thelucky/p/5608446.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!