javascript - Enter key in textarea -


i have textarea, on every enter key pressed in textarea want new line started bullet (*). how go ?

no jquery please.

i can observe enter key , after !? should have whole value of textarea , append * , again fill textarea ?

you this:

<body>  <textarea id="txtarea" onkeypress="ontestchange();"></textarea>  <script> function ontestchange() {     var key = window.event.keycode;      // if user has pressed enter     if (key === 13) {         document.getelementbyid("txtarea").value = document.getelementbyid("txtarea").value + "\n*";         return false;     }     else {         return true;     } } </script>  </body> 

although new line character feed pressing enter still there, start getting want.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -