jQuery动画< object>标签 [英] jQuery animate <object> tag

查看:45
本文介绍了jQuery动画< object>标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个<object>,其id为'objectID'.

I have an <object> with an id of 'objectID'.

我可以使用.css修改其位置:

I can modify its position with .css:

$('#objectID').css({'top': "+=200px"});

但是当我使用.animate时,它将无法正常工作:

But when I use .animate it won't work:

$('#objectID').animate({'top': "+=100px"}, 1000);

$('#objectID').animate({top: "10"}, slow);

或其他适用于div的变体.动画object元素是否有限制?

Or any other variation, which works on divs. Is there a limitation to animating object elements?

推荐答案

由于不支持<object>标签,因此您可以像这样修改自己的动画:

Since the <object> tag is not supported you can hack out your own animation like this:

var obj = $('#objectID');
var speed = 50;
var distance = 100;

var i = setInterval(function() {
    obj.css({'top': '+=1px' });
    if (parseInt(obj.css('top')) > distance) {
        clearInterval(i);
    }
}, speed);

更改speed变量以获得所需的动画速度.

Change the speed variable to get the animation speed you need.

这是jsfiddle .

这篇关于jQuery动画&lt; object&gt;标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆