首页javascripttext_inputjQuery Form - 如何显示您在文本字段中键入的内容

jQuery Form - 如何显示您在文本字段中键入的内容

我们想知道如何显示您在文本字段中键入的内容。


<html>
  <head>
    <script type="text/javascript" src='http://code.jquery.com/jquery-1.5.2.js'></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $("input").keypress(function (e) {
                var c = String.fromCharCode(e.which);
                $("p").append($("<span/>")).children(":last").append(document.createTextNode(c));
                $("div").text(e.which);
            });
        });
    </script>
  </head>
  <body>
     <input type="text" />
      <p>Add text - </p>
      <div></div>
  </body>
</html>