1、trigger()
trigger()是主動觸發(fā),意思就是說不需要做人為操作自己就會觸發(fā)茉帅。
$('#div1').on('click',function(){
$(this).animate({width:300},1000,'linear')
})
$('#div1').trigger('click')
注意trigger()接收的參數(shù)
2、e.data/type
$('#div1').on('click',{name:'limingru'},function(e){
console.log(e.data.name)
console.log(e.type)
console.log(e.target)
})
在事件綁定的函數(shù)里我們是沒有辦法傳遞參數(shù)的锭弊,因為它只有一個默認的e而且是在觸發(fā)事件的時候才會傳遞。如果想要傳遞一些參數(shù)進去擂错,就只能用e.data味滞,e.data就是中間那個對象。