我正在努力将一个元素赋值给一个变量 - 我是否在这里忽略了阴谋?将元素赋值给一个变量
animationupgrades = [{
animation: "height",
target: $('#element'),
effect: 33,
finished: 23
}];
var thisIndex = 0; //as an example
var aniAttribute = animationupgrades[thisIndex].animation;
var target = animationupgrades[thisIndex].target;
var effect = animationupgrades[thisIndex].effect;
var finished = animationupgrades[thisIndex].finished;
$(target).on('mouseover', function() {
$(this).stop().animate({
aniAttribute : effect
},500);
console.log("errr");
}).on('mouseout', function() {
$(this).stop().animate({
aniAttribute : finished
},500);
});
编辑:对不起,它实际上是一个对象 - 我错了!为什么所有的降价?
edit2:小提琴! http://jsfiddle.net/28wone62/
你错过了,这是一个错字括号 – 2014-10-29 23:09:33
- 我已经纠正了现在 - 道歉 – 2014-10-29 23:10:38
我没有downvote你,这就是我认为错字 – 2014-10-29 23:12:28