首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在jquery中$( this )和this之间的区别

在jquery中$( this )和this之间的区别
EN

Stack Overflow用户
提问于 2010-09-03 13:37:00
回答 5查看 26.2K关注 0票数 69

使用$( this )与使用$(This)之间的根本区别是什么

代码语言:javascript
复制
$('.viewComments').click(function(ev){
    //returns the desired value
    alert(this.getAttribute('id'));

    //Gives an error sayin function is not defined 
    alert($(this).getAttribute('id'));

    //returns the desired value
    alert($(this).attr('id'));
});

我认为"$(this)“将包含"this”所具有的所有函数,而more..But似乎不是这样的。

那么$(this)到底是什么呢?和

当我使用它时,我怎么知道有哪些功能可用?(我知道我可以让他们通过firebug。但我想知道是否有其他方法-一些文档可能是)

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3633270

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档