jquery - Using .val to populate textarea -


i'm trying populate text area values multiple inputs typed, problem everytime go new input, clears previous information text area , adds new, there anyway can keep information previous fields , add new info.

html

<input type="text" name="fname" ><br> <input type="text" name="lname"><br>  <textarea type="text" id="content"></textarea><br> 

jquery

  $("input").keyup(function () {   var value = $(this).val();   $("#content").text(value);   }).keyup(); 

codepen http://codepen.io/michael52/pen/uzeqs

why don't build textarea's content based on other 2 boxes, not old value of textarea:

<input type="text" name="fname" id="fname"><br> <input type="text" name="lname" id="lname"><br>  <textarea type="text" id="content"></textarea><br> 

js:

$("input").keyup(function () {   var value = $('#fname').val() + ' ' + $('#lname').val();   $("#content").text(value); }).keyup(); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -