1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta charset="UTF-8">
5 <title>Title</title>
6 <script src="lib/jquery-1.12.2.js"></script>
7 <script>
8 $(function () {
9 $('[type="text"]').val(); // 获取
10 $('[type="text"]').val('你好,大家都饿了'); // 修改
11 $('textarea').val('你好,我有点饱');
12 $('div').html() ; // 获取
13 $('div').html('<p>duanluo</p>') ; // 修改
14 console.log($('ul').text()); //获取
15 $('div').text('<p>duanluo</p>') ; // 修改
16 /**
17 * 其中.html()
18 * 如果选择器匹配多于一个的元素,那么只有第一个匹配元素的 HTML 内容会被获取(唯一性)
19 *
20 *.text()
21 * 只能设置文本内容不能设置html样式
22 * */
23
24 });
25 </script>
26 </head>
27 <body>
28 <input type="text">
29 <input type="password">
30 <textarea name="" id="" cols="30" rows="10"></textarea>
31 <h2>普通标签</h2>
32 <div>文字内容</div>
33 <ul>
34 <li>列表项</li>
35 <li>列表项</li>
36 <li>列表项</li>
37 </ul>
38
39 </body>
40 </html>