I want to add text inside Textarea. Text should be added immediately after the cursor position, and not at the end.
Here is my code:
HTML:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <textarea id="textarea1"></textarea> <br><input type="button" value="Write blah blah" onclick="addtxt('textarea1')"> </body> </html>
Script:
<script> function addtxt(input) { var obj=document.getElementById(input); obj.value+="blah test 123" } </script>
The above code is in real time: http://jsfiddle.net/zGrkF/
Thanks in advance.
source share