[英]How to print text to a textarea?
I have this code : 我有这个代码:
<script type="text/javascript">
function GetChar(event) {
var chCode = ('charCode' in event) ? event.charCode : event.keyCode;
if (chCode == 13) {
var textBox = document.getElementById('TEXTBOX');
alert("The text in the box is: " + textBox.value);
document.getElementById('test').innerHTML = ("The text in the box is: " + textBox.value);
if (textBox.value == 'ninja') document.getElementById('teraminal').innerHTML = ("working!")
}
}
</script>
HTML: HTML:
<input type="text" id="TEXTBOX" size="40" value="" onKeyPress="GetChar (event);" />
<label id="test"></label>
<textarea rows="40" cols="80" readonly id="terminal" draggable="false" style="resize:none">
I want it to say "working" in the <textarea>
when I type "ninja", but it's not working. 当我键入“忍者”时,我希望它在
<textarea>
说“正在工作”,但它不工作。 Any ideas on how to fix it? 关于如何解决它的任何想法?
设置value
属性,而不是innerHTML
属性,并一致地拼写terminal
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.