gpt4 book ai didi

javascript - 如何获取类属性?

转载 作者:行者123 更新时间:2023-11-28 21:01:47 25 4
gpt4 key购买 nike

我有这个代码:

function myClass() {

this.tabs = new Array();

myClass.prototype.focus_tab = function animateTab(nr){
for(i=0;i<this.tabs.length;i++){
$('#' + i + '-image').stop().animate(
{ left: '100px' },
100 , function(){
this.tabs[i].step = 1;
}
);
}
}

但是动画末尾的函数无法识别“this.tabs”。如何做好?

最佳答案

它在不同的范围内,请尝试:

function myClass() {
this.tabs = new Array();

myClass.prototype.focus_tab = function animateTab(nr){
for(i=0;i<this.tabs.length;i++){
var mytab = this.tabs[i];
$('#' + i + '-image').stop().animate({ left: '100px' }, 100 , function(){
mytab.step = 1;
}
);
}
}

还有一些其他问题,但对该问题的评论已经解决了其中的一些问题!

关于javascript - 如何获取类属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10820709/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com