Is it possible to somehow add template text to <textarea> ? Suppose there is a button on the site (implemented through <a> or <input> ), by clicking on which a template line will be added to the text input field. Or is it better to do all this through a <div> ?
|
1 answer
Here is an example:
<!DOCTYPE html> <html> <body> <textarea id="myTextarea"> Какой-то текст, бла бла </textarea> <br> <button type="button" onclick="myFunction()">Жми</button> <script> function myFunction() { document.getElementById("myTextarea").value = "Пример текста"; } </script> </body> </html> - And can this be done without harming the entire text? Those. just add at the end of the sentence - NTP
- Did not quite understand what you need :) - user242433
- onedocument.getElementById ("myTextarea"). value = document.getElementById ("myTextarea"). value + "Sample Text"; - Rostyslav Kuzmovych
- @RostyslavKuzmovych, exactly, thanks - NTP
- oneOr using Jquery,
$('a').click(function(){ var text = "text"; $('#myTextarea').append(text); });user242433
|