用于将大黑点(?)插入 html textarea 的 Javascript 按钮
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12159286/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Javascript button to insert a big black dot (?) into a html textarea
提问by Brice
I have a textarea
in a html form
and I would like to have a button to add a big black dot character (?) (is this called a bullet?) into this textarea
. is it possible in javascript
?
我有一个textarea
in ahtml form
并且我想要一个按钮来添加一个大黑点字符(?)(这叫做子弹吗?)到这个textarea
. 有可能javascript
吗?
Also it needs to be a UTF8
character.
它也需要是一个UTF8
字符。
Thanks for your help!
谢谢你的帮助!
回答by Quentin
Just access the element and append it to the value.
只需访问元素并将其附加到值。
<input
type="button"
onclick="document.getElementById('myTextArea').value += '?'"
value="Add ?">
See a live demo.
观看现场演示。
For the sake of keeping things simple, I haven't written unobtrusive JS. For a production system you should.
为了简单起见,我没有编写不引人注目的 JS。对于生产系统,您应该这样做。
Also it needs to be a UTF8 character.
它也需要是一个 UTF8 字符。
Browsers generally submit forms using the encoding they received the page in. Serve your page as UTF-8 if you want UTF-8 data submitted back.
浏览器通常使用它们接收页面的编码提交表单。如果您希望返回 UTF-8 数据,请将您的页面作为 UTF-8 提供。
回答by Veysi YILDIZ
you can use html entity as •
您可以使用 html 实体作为 •