为什么以及何时使用 $(this)
而不是 this
?
最佳答案
当您位于 DOM 对象(或任何其他与此相关的对象)的范围内时,您可以使用 this
例如:
$('a').click(function(){
var href = $(this).prop('href'); //refers to to this a tags href
var href1 = this.href; //ALSO refers to to this a tags href
})
关于javascript - jQuery '$(this)',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5911690/