导航

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

Posted on 2014-07-04 19:24  网名还没想好  阅读(1232)  评论(0编辑  收藏  举报
<p><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<a href="http://www.w3.org/TR/html4/loose.dtd">http://www.w3.org/TR/html4/loose.dtd</a>">
<html>
 <head>
  <title> this----$(this)区别 </title>
  <meta name="Author" content="lushuaiyin">
  <script type="text/javascript" src="jquery-1.7.1.js"></script>
 </head></p><p> <body>
 <input type="text" id="dd" value="gg" />
 </body>
</html></p><p><script>
$("#dd").click( 
  
  function () { 
      alert("this取值:"+this.value+"--"+this);//this是js中返回html对象,所以要这样用。
   alert("$(this)取值:"+$(this).val()+"--"+$(this));//$(this)返回封装后的jquery对象,所以要用jquery的方法。
  }
);
</script>
</p>

摘自:http://blog.csdn.net/lushuaiyin/article/details/7609389