在下面的代码中,为什么需要用$函数将'this'括起来?
var x = $('div');
x.click(function(){
$(this).hide();
});
“this”不是指的是表达式 x,它本身就是一个 jQuery 对象吗?
最佳答案
this
的值将是表示被单击元素的 DOM 节点。 $(this)
将是一个包装该 DOM 节点的 jQuery 对象,并提供额外的函数,如 .show()
、.append()
、等等
关于javascript - 在 'this' 上调用 jQuery $ 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14963841/