我将如何更改 <textarea>
的内容使用 JavaScript 元素?
我想让它变空。
最佳答案
像这样:
document.getElementById('myTextarea').value = '';
或者在 jQuery 中像这样:
$('#myTextarea').val('');
你在哪里
<textarea id="myTextarea" name="something">This text gets removed</textarea>
对于所有反对者和非信徒:
-
value Property: Retrieves or sets the text in the entry field of the textArea element.
-
value DOMString The raw value contained in the control.
关于javascript - 如何使用 JavaScript 更改 <textarea> 的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1642447/