我可以动画#ID Div 标签来移动,但我不能调用 .class Div 标签来移动。我怎样才能正确地做到这一点?
.myClass {
width: 40px; height: 40px;float:left;padding: 1px; margin:3px;
position:absolute; left:50px; top:60px; background:blue; color:white;
}
在 HTML 中:
<div class="myClass">Insert image2</div>
<div class="myClass"><img src="jef-frog.gif"width="50">DIV myCLASS</img></div>
function randomRange(min,max) {
return Math.random() * (max-min) + min;
}
/* Generate some random starting position */
var startmyClassX = randomRange(50,100);
var startmyClassY = randomRange(50,100);
var item2 = $(".myClass"),cycle1;
function runItem2() {
/* Set a the starting position to be random by editing the css */
$(".myClass").css("left", startItem2X+"px");
$(".myClass").css("top", startItem2Y+"px");
$(".myClass").svg(onLoad);
(cycle2 = function() {
var m = randomRange(50,100);
var n = randomRange(75,150);
myClass.animate({top:'+='+m, left:'+='+n},2000);
myClass.animate({left:'-='+n},2000);
myClass.animate({left:'+='+n, top:'-='+n},2000);
myClass.animate({left:'-='+n},2000)
myClass.animate({top:'+='+m},2000,cycle2)
})();
}
runItem2();
任何人都可以帮助解决这个问题?谢谢