0

I have two arrays:

var rects = []; //for svg rect image objects

function create() {
  for(var i=0; i<6; i++) {
     var rect = document.createElementNS(NS, 'rect');
     rect.setAttributeNS(null, "id", "rect"+i); 
     rects.push(rect);
     var r = rects[i];
     document.getElementById('svgOne').appendChild(r); 
     move(i);
  }
}

function move(i) {
   $('#'+rects[i].id).animate({top: '100px'}, 3000);
}

but move() dosen't working. I want see animate().
already use console.log(rects[i]). but no problem.

kanok ja
  • 21
  • 1
  • 6
  • just console.log whaterver is in rects[i] to see what's in there. – Andrew Nov 08 '15 at 17:46
  • just call `move(i)` so the current `i` will be passed to `move` and the element at this index in `rescts` will move. – pawel Nov 08 '15 at 19:23
  • oh i skipped i. I fix that. but still doesn't working – kanok ja Nov 08 '15 at 19:28
  • `{ top: '100px'}` is something you'd use with an HTML node, but SVG elements don't have `top` property (it would be `y`) and they don't use units, so you should animate `{ y : 100 }` BUT jQuery `.animate` animates CSS properties, not attributes: http://stackoverflow.com/questions/17360739/jquery-animate-for-element-attributes-not-style – pawel Nov 08 '15 at 19:45

0 Answers0