How to rotate a div using JavaScript?
<p>I want to rotate this div 180 degres when user clicks a button.</p>
<pre><code>&lt;div class=&quot;game-wrapper&quot;&gt;
...
&lt;/div&gt;
</code></pre>
<p>I have this code in JavaScript.</p>
<pre><code>$scope.rotate = function () {
    var x = document.getElementsByClassName(&quot;game-wrapper&quot;);
    x.style.transform = &quot;rotate(180deg)&quot;;
}
</code></pre>
<p>And I'm getting this error:</p>
<blockquote>
<p>TypeError: Cannot set property 'transform' of undefined</p>
<p>at Scope.$scope.rotate (controllers.js:421)</p>
</blockquote>
<p>I'm also using AngularJS.</p>