title: SVG getAttribute/setAttribute simply adding to coordinates instead of "setting"?
body: <pre><code>&lt;svg width="100%" height="100%"
      xmlns="http://www.w3.org/2000/svg" version="1.1" 
      xmlns:xlink="http://www.w3.org/1999/xlink"
      onload="startup(evt)"&gt;
  &lt;script&gt;
  function startup(evt){
      svgDoc=evt.target.ownerDocument;
      setInterval(function(){step("zero");},1000);
      setInterval(function(){follow("zero","one");},950);
  }
  
  function step(e,follower){
      e=svgDoc.getElementById(e);
      var rand = Math.floor((Math.random()*2)+1);
      var rand2 = Math.floor((Math.random()*2)+1);
      var move = 10;
      var y = +(e.getAttribute("y"));
      var x = +(e.getAttribute("x"));
      if(rand == 1){  
          if(rand2 == 1){
          e.setAttribute("y",y + move);
          } else {
          e.setAttribute("y",y - move);
          }
      } else {
      if(rand2 == 1){
          e.setAttribute("x",x + move);
          } else {
          e.setAttribute("x",x - move);
          }
      }
  }
  function follow(leader, follower){
      follower = svgDoc.getElementById(follower);
      leader = svgDoc.getElementById(leader);
  
      var leaderY = leader.getAttribute("y");
      var leaderX = leader.getAttribute("x");
  
      follower.setAttribute("y", leaderY);
      follower.setAttribute("x", leaderX);
  }
  
  &lt;/script&gt;   
  &lt;defs&gt;
      &lt;text id="zero"&gt;0&lt;/text&gt;
      &lt;text id="one"&gt;1&lt;/text&gt;
  &lt;/defs&gt;
  &lt;use x="50" y="50" xlink:href="#zero"/&gt;
  &lt;use x="10" y="10" xlink:href="#one"/&gt;
  &lt;/svg&gt;
  </code></pre>
  
  <p>Just doing some random exercises to build my logic and practice scripting.</p>
  
  <p>Basically, I mean for the "one" to follow the "zero". The zero moves randomly, and it's position is put into memory /stored a tiny bit (50ms) before it is suppose to move. The one is then meant to be set to this position. Instead, I just get the "One" following the movement pattern of the "Zero", instead of its previous position. I'm curious to why this is, because I am not doing any sort of actual addition to the "one" svg element.</p>