Insert special characters in textbox

泄露秘密 提交于 2019-12-08 01:44:42

问题


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


回答1:


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



回答2:


On the button click, simply append the character you require to the string that is already in the text box. An example of this is here



来源:https://stackoverflow.com/questions/18076895/insert-special-characters-in-textbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!