在jQuery中使用選擇器找到節(jié)點后在箭頭函數(shù)中使用$(this)會被定位到整個頁面
$('.class').(()=>{console.log($(this))})
===>window
如果想使用$(this)來定位選定的元素應使用function
$('.class').(function(){console.log($(this))})
===>.class
在jQuery中使用選擇器找到節(jié)點后在箭頭函數(shù)中使用$(this)會被定位到整個頁面
$('.class').(()=>{console.log($(this))})
===>window
如果想使用$(this)來定位選定的元素應使用function
$('.class').(function(){console.log($(this))})
===>.class