我有这段代码可以出色地重置表单
<script type="text/javascript">
$("#formname").resetForm();
</script>
但我想只清除文本区域。这可能吗?
最佳答案
清除和重置是两个不同的东西。 Clears 表示将值设置为空字符串,而 Reset 表示将值设置为其初始值。
清除:
$('#textAreaId').val('');// clears the textarea.
重置为文本区域初始值,而不是仅仅重置它:
var t = document.getElementById('textAreaId');
t.value = t.defaultValue;
defaultValue The default value as originally specified in HTML that created this object.
关于javascript - 仅清除表单中的 <textarea>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15938459/