源自:4-1 JS多物体动画
用jQuery实现时出错,请大神帮看看
var $li = $('li');
$li.on('mouseover', function () {
mutipleMove($(this), 400)
})
$li.on('mouseout', function () {
mutipleMove($(this), 200)
})
function mutipleMove(obj, target) {
clearInterval(obj.timer);
var speed = 0;
if (obj.width() > target) {
speed = -10;
}
else {
speed = 10;
}
obj.timer = setInterval(function () {
if (obj.width() == target) {
clearInterval(obj.timer)
}
else {
obj.css({
'width': '+=' + speed + ''
})
}
}, 30)
}
哪里错了??
提问者:杨辰沁再不疯狂就老了
2017-04-10 14:54