码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2016-05-18 21:13:37      阅读:141      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!