首页 > Web开发 > 详细

第二十节 jQuery操作属性

时间:2020-03-14 21:34:56      阅读:66      评论:0      收藏:0      [点我收藏+]
 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>Document</title>
 6     <script type="text/javascript" src="../jquery-1.12.4.min.js"></script>
 7     <script type="text/javascript">
 8         $(function(){
 9             var $a = $(.link);
10 
11             // 读取class属性值,没有设置的属性读取为空,读取的图片地址为完整的绝对地址
12             console.log($a.prop(class));
13             console.log($a.prop(title));
14 
15             // 设置属性值
16             $a.prop({href:http://www.baidu.com,title:百度网链接});
17 
18             // 读标签里的内容
19             console.log($a.html());
20 
21             // 往标签内写内容
22             console.log($a.html(这是再次写入的内容))
23         });
24     </script>
25 </head>
26 <body>
27     <a href="#" class="link">这是一个链接</a>
28 </body>
29 </html>

 

第二十节 jQuery操作属性

原文:https://www.cnblogs.com/kogmaw/p/12493779.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!