【发布时间】:2018-09-06 10:10:38
【问题描述】:
我正在创建一个cmets部分,但是有一个问题:点击post时如何将输入值设为空白?
<input type="text" value="" id="stuffed" />
<button onclick="post()">Post</button>
<script>
function post(){
var x = document.getElementById("stuffed").value;
document.getElementById("paragraph").innerHTML = "<me> " + x;
}
</script>
<p style="color: #ffffff;" id="paragraph"></p>
这样会发布评论(稍后我将使用 css 来装饰它),但在它说“评论”的地方仍然有之前发布的评论。你如何将它的值返回为空白?
【问题讨论】:
-
重置表格,不是吗?或
document.getElementById("stuffed").value=""? -
@whoever 编辑了我的代码 感谢您的帮助,但它不是 xHTML。不过还是谢谢
标签: javascript css html