zoukankan      html  css  js  c++  java
  • JS小练习 留言功能

     1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     2 <html xmlns="http://www.w3.org/1999/xhtml">
     3 <head>
     4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     5 <title>无标题文档</title>
     6 <script src="jquery-1.11.2.min.js"></script>//接入jquery包
     7 </head>
     8 
     9 <body>
    10 <div id="nr">
    11 </div>
    12 <div>
    13     内容:<textarea id="txt"></textarea>
    14     <br />  
    15     <input type="button" value="提交" id="btn" />
    16 </div>
    17 </body>
    18 <script type="text/javascript">
    19 //给提交按钮加入点击事件
    20 $(document).ready(function(e) {
    21     //找到ID=btn的按钮加入一个click事件
    22     $("#btn").click(function(){
    23         //首先要找到文本域里面的值
    24         var nt = $("#txt").val();//取出用户在文本域里面输入的valuer值并且交给一个变量nt
    25         
    26         var str = nt+"<br>";//在用户输入的内容后面追加换行
    27         //把拼接好的字符串(nt+"<br>")扔到最上方ID为nr的DIV里面去
    28         $("#nr").append(str); 
    29             
    30         })
    31 });
    32 
    33 
    34 </script>
    35 </html>
  • 相关阅读:
    Python(多进程multiprocessing模块)
    Python(队列)
    Unique Paths
    Unique Paths
    Jump Game II
    Jump Game
    Path Sum II
    Path Sum
    Remove Element
    Implement strStr()
  • 原文地址:https://www.cnblogs.com/hanqishihu/p/5609819.html
Copyright © 2011-2022 走看看