Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the Document</title> </head> <body> <input id="inputId" style="width:200px" value="Text Text Text Text Text"> <button id="buttonId">Insert "WELCOME" at cursor</button> <script> buttonId.onclick = () => { inputId.setRangeText("WELCOME", inputId.selectionStart, inputId.selectionEnd, "end"); inputId.focus(); }; </script> </body> </html>