$("#foo").on("click", function() {
amountItems.speek('heey')
})
var amountItems = (function(el) {
// var el = el;
return {
speek: function() {
alert(el)
}
}
}())
這是我第一次嘗試使用模塊模式。基本上當foo被點擊時,我想要調用amountItems函數內的speek方法,並且我想將字符串'heey'傳遞給方法,所以當點擊foo時它應該提醒'heey'。最初我想傳遞像$(「#foo」)。text()這樣的東西,但是我得到'undefined'。將參數傳遞給模塊模式函數時得到未定義
你可以告訴我如何使用jQuery對象時,它傳遞到這種類型的函數?