javascript: How would you make text spin using javascript?
<p>I have this code:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;img src="http://www.w3schools.com/html/html5.gif" id="imgid"&gt;
&lt;h1 id='header'&gt;Example&lt;/h1&gt;
&lt;!--This is an example html doc not the real thing!--&gt;
&lt;button onclick="spin(document.getElementById('header'));spin(document.getElementById('imgid'));"&gt;Spin!&lt;/button&gt;
&lt;script&gt;
  function spin(object) {
    setInterval(function() {
      object.style.transform += "rotate(10deg)";
    }, 1);
  }
&lt;/script&gt;</code></pre>
</div>
</div>
</p>

<p>How do I make the text spin correctly? If you could explain how it works then that would be great. If you need any references of my sources then:</p>

<ul>
<li><a href="http://www.w3schools.com/jsref/met_win_setinterval.asp" rel="nofollow noreferrer"><code>SetInterval</code></a></li>
<li><a href="http://www.w3schools.com/jsref/prop_style_transform.asp" rel="nofollow noreferrer"><code>style.transform</code></a></li>
</ul>

<p>By "correctly" I mean spinning centered. (Not all over the page).</p>

<p>Thanks!</p>