在文本框中插入特殊字符 [英] Insert special characters in textbox

查看:152
本文介绍了在文本框中插入特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个文本框,我想通过点击一个按钮来添加一些文本(不删除已有的文本)。是可能的吗?



我将要添加的文本将是一些html特殊字符代码,如é显示一个é...

,或者也可以做相反的事情,比如我写一个é,然后当我提交它时改变为é这种方式对用户来说更容易



在此先感谢 解决方案

pre> < input type =textid =txt/>
< input type =buttonvalue =Addtextonclick =addText()/>
< script>
函数addText(){
document.getElementById('txt')。value + =sometextàéèìòù;
}
< / script>


So I have a textbox and I want to add some text( without deleting the one I already have) by clicking a button.. is that possible?

The text I'll be adding will be some html special characters code like é to show a "é"...

or maybe do the reverse, like I write a "é" and then when I submit it changes to é this way it will be easier to the user

Thanks in advance

解决方案

<input type="text" id="txt" />
<input type="button" value="Addtext" onclick="addText()" />
<script>
    function addText() {
        document.getElementById('txt').value += "sometextàéèìòù";
    }
</script>

这篇关于在文本框中插入特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆