首页 > 代码库 > jquery 替换文本内容

jquery 替换文本内容

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4     <meta charset="utf-8">
 5     <meta http-equiv="X-UA-Compatible" content="IE=edge">
 6     <title></title>
 7     <script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
 8 </head>
 9 <style>
10   #btnTex{width:80px; height:50px; margin: 10px;}
11   
12 </style>
13 <body>
14   
15 <input id="text1" type="text" />
16 <input id="btn1" type="button" value="按钮" />
17 <p id="p1">这是一些文字</p>
18     <script  type="text/javascript" charset="utf-8">
19        $(function(){
20               var text1 = $(#text1);
21               var btn1 = $(#btn1);
22               var p1 = $(#p1);
23                btn1.click(function(){
24                 p1.html(text1.val());
25 
26               })
27             
28         
29           
30              
31        })
32    </script>  
33 </body>
34 </html>

 

jquery 替换文本内容