this 和 $(this) 在像 create 这样的小部件方法中是什么意思?
例如,有这样一个小部件,
$.widget("sample.CustomWidget", {
options:{
},
_create: function(){
// Here what do this and $(this) mean
}
});
提前致谢
-拉惹。
最佳答案
它基本上取决于 _create 方法的调用者......无论如何:
this
指的是函数的“所有者”$(this)
就是把上面的对象包装成一个jQuery对象
另见:
http://www.quirksmode.org/js/this.html
http://www.bennadel.com/blog/1838-Wrapping-The-Window-Object-In-A-jQuery-Wrapper.htm
关于javascript - 小部件中的 this 和 $(this),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9943493/