首页 > Web开发 > 详细

jQuery中this与$(this)的区别实例

时间:2016-05-18 21:13:00      阅读:162      评论:0      收藏:0      [点我收藏+]
 1 <!doctype html>
 2 <html>
 3 <head>
 4 <meta charset="utf-8">
 5 <title>this</title>
 6 <script type="text/javascript" src="js/jquery.js"></script>
 7 </head>
 8 <body>
 9 <input type="text" id="dd" value="gg"/>
10 <script>
11    $("#dd").click(
12      function(){
13         alert("this取值:"+this.value+"--"+this);//this是js中返回html对象,所以要这样用。
14        alert("$(this)取值:"+$(this).val()+"--"+$(this));//$(this)返回封装后的jquery对象,所以要用jquery的方法。
15      }
16    )
17 </script>
18 </body>
19 </html>

 

jQuery中this与$(this)的区别实例

原文:http://www.cnblogs.com/dreamflower/p/5506157.html

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