【发布时间】:2013-01-23 21:25:41
【问题描述】:
我正在尝试编写一个执行幻灯片放映的脚本。我可以用函数来做,但我想使用原型方法。我很难弄清楚的是程序。这是我尝试做的事情
var displayVars = {
slide: '',
thumb: ''
}
//setup display
display = function(slide,thumb) {
displayVars.slide = $(slide);
displayVars.thumb = $(thumb);
// set slider width
}
display.prototype.play = function() {
// move slide to this location
display.hightlight();
}
display.prototype.hightlight = function() {
// add border to element
}
$(function() {
newdis = new display('.show-slide','.window-thumbs');
displayVars.timer = setTimeout(newdis.play,500);
});
如果你在播放函数中注意到我想调用 highlight 方法。我真正想要的是每次调用 play 函数时都运行 highlight 函数。我无法理解如何做到这一点,因为“显示”或“这个”不会让我访问突出显示功能。
【问题讨论】:
-
this确实会让你调用“highlight”函数。
标签: javascript oop prototype