首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

jquery this跟$(this)

2012-11-12 
jquery this和$(this)起初以为this和$(this)就是一模子刻出来。但是我在阅读时,和coding时发现,总不是一回

jquery this和$(this)

起初以为this和$(this)就是一模子刻出来。但是我在阅读时,和coding时发现,总不是一回事。

What is "this"?

In many object-oriented programming languages, this (or self) is a keyword which can be used in instance methods to refer to the object on which the currently executing method has been invoked.

?

正确的代码:$("#textbox").hover(      function() {         $(this).attr(’title’, ‘Test’);      },      function() {         $(this).attr(’title’, ‘OK’);      });
?使用JQuery的好处是它包裝了各种浏览器版本对DOM对象的操作,因此统一使用$(this)而不再用this应该是比较不错的选择。

原文链接 http://www.cnblogs.com/RuiLei/archive/2009/08/20/1550804.html

热点排行