问题
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