3

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

I can modify its position with .css:

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

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

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

or

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

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


Regular expression javascript to check comma separted numbers

can somebody help me write a regex to use with test function for find exactly received number on list of string or numbers that has comma separated numbers.

For ex. I have number 125 like argument and string like '12,74,48,125,1253,1' or if it more easy to use list of numbers 12,74,48,125,1253,1 (I can use both) How can I write regex to find exactly this number and return true o false.

I used this one, but it don't find if number has 3 o 4 digits

if(new RegExp('\\b'+number+'\\b').test('12,74,48,125,1253,1')){
alert('true');
}

This list can also be just only one number like '125' I have little practice with regex. Thanks in advance.

4

4 回答 4

3

由于<object>不支持该标签,您可以像这样破解自己的动画:

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);

更改速度变量以获得您需要的动画速度。

这是 jsfiddle

于 2012-05-01T14:50:42.373 回答
0

为了与顶部动画,您的元素需要位置,例如位置:相对或位置:绝对。

于 2012-05-01T14:27:26.923 回答
0

您是否为此对象包含了适当的 css?

​#objectID{
  position: absolute;
  top: 0px;
  ...
}​

确实我相信Object可能不会被支持animate()。我能够.css在 jsfiddle 中使用。

不过应该可以使用:http .css(): //jsfiddle.net/mkprogramming/bw9Kb/15/

于 2012-05-01T14:29:11.370 回答
0

$('#objectID').animate({'top': "+=100px"}, 1000); 周围不需要引号top

$('#objectID').animate({top: "10"}, slow); 整数不应被引号包围,而slow应被引号包围。

那应该可以解决您的问题。

于 2012-05-01T14:29:22.733 回答