javascript - Jquery :How to store textbox value clientside and display? -


the below code update display value enter user in textbox when button clicked in code not preserve previous value enter user .

<h1>type comment below </h1> <input id="txt_name" type="text" value="" />     <button id="get">submit</button>  <div id="textdiv"></div> -  <div id="datediv"></div> 
jquery(function(){     $("button").click(function() {         var value = $("#txt_name").val();          $("#textdiv").text(value);         $("#datediv").text(new date().tostring());     }); }); 

now want preserve value enter user , when user submit button show both value previous current.

how achieve ?

can below code preserve value

var $input = $('#inputid');     $input.data('persist', $input.val() ); 

if yes how display value previous,current etc. when user click on button ?

if got right, need?

<h1>type comment below </h1>  <input id="txt_name" type="text" value="" />  <button id="get">submit</button>   <script type="text/javascript">     jquery(function(){     $("button").click(function() {       var value = $("#txt_name").val();        $("#section").prepend('<div class="textdiv">'+value+'</div>')       $("#section").prepend('<div class="datediv">'+new date().tostring()+'</div>')       $("#txt_name").val('');     }); }); </script>  <!-- each time press submit, new line pushed here --> <div id="section"> </div> 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -