[英]How to add more text to textarea
I want to create console. 我要创建控制台。
I have textarea: 我有textarea:
<textarea style="width: 100%; height: 300px; resize: none;" id="console_output" readonly></textarea>
And using this code to insert more text: 并使用此代码插入更多文本:
else echo "<script>$('#console_output').append('Some text.\n');</script>";
But nothing happened, textarea is empty. 但是什么也没发生,textarea是空的。
Your code should work as you can check JsFiddle 您的代码应该可以正常工作,因为您可以检查JsFiddle
$('#console_output').append('Some text.\n');
Will not work if 如果不起作用
You can try with pure js: 您可以尝试使用纯js:
echo '<script>document.getElementById("console_output").value += "Some text.\n";</script>';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.