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();
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
Post a Comment