javascript - Show what the user typed in the body -


i have code , want after user type in textfield , press enter, typed appears on screen. i'm not being able that, i'd here.

<!doctype html> <html> <head> <title>tasks day</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>  <script>  alert("when have finished task have click on it.");  $(document).ready(function(){ $("p").click(function(){     $(this).hide(); }); });  $(document).keypress(function(e) { if(e.which == 13) {  } });  function showmsg(){  var userinput = document.getelementbyid('userinput').value;   document.getelementbyid('usermsg').innerhtml = userinput; }  </script> </head> <body>  <h1>tasks do</h1>  <p>type need do:</p>  <input type="input" id="userinput" onkeyup=showmsg() value="" /> <p id="usermsg"></p>  </body> </html> 

it adds 1 value screen, put more one, need create array

  1. you had main components working. namely, updating screen. have update on enter, put code in keypress handler
  2. to append value screen(in case of more 1 enter), concatenate current innerhtml value

$(document).ready(function() {    $("p").click(function() {      $(this).hide();    });  });    $('#userinput').keypress(function(e) {    if (e.which == 13) {      var userinput = document.getelementbyid('userinput').value;      var innerhtml = document.getelementbyid('usermsg').innerhtml;      innerhtml = innerhtml || '';      document.getelementbyid('usermsg').innerhtml += innerhtml + userinput;    }  });
<title>tasks day</title>  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>    <h1>tasks do</h1>    <p>type need do:</p>    <input type="input" id="userinput" onkeyup=showmsg() value="" />  <p id="usermsg"></p>


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -