【发布时间】:2014-01-03 15:01:36
【问题描述】:
this.slideUpComm = function (){
$("#Day-events-content p").addClass("hidden").slideUp("fast");
}
this.showhideEvents = function() {
$("#Day-events-content").on("click", ".eventsToggle", function() {
var obj = $(this).next();
if ($(obj).hasClass("hidden")) {
slideUpComm();
$(obj).removeClass("hidden").slideDown();
} else {
$(obj).addClass("hidden").slideUp();
}
});
}
我想使用 slideUpComm 作为我包含在不同事件中的函数,但控制台返回 Uncaught ReferenceError: slideUpComm is not defined。 我应该如何将函数传递给函数?我应该使用回调吗?
function dateObj() {
this.d = new Date();
this.day = this.d.getDate();
this.numDay = this.d.getDay();
this.month = parseInt(this.d.getMonth());
this.year = this.d.getFullYear();
this.slideUpComm = function (){
}
this.showhideEvents = function() {
});
}
}
我的对象如上所示。
【问题讨论】:
-
什么是
this,你是如何调用函数的?
标签: javascript jquery callback closures