title: JavaScript: Rotate img on click
body: <p>I'm trying to make the img with the id image rotate using the onclick event handler to use the code in my function which grabs the image by ID assigns a variable name, then uses the variable name to rotate. I'm not really sure where i when wrong in my code.</p>
  
  <pre><code>   &lt;section id="middle"&gt;
      &lt;img id="image" src="images/flower.png" &gt;   
      &lt;button onclick="myFunction()"&gt;Click me&lt;/button&gt;
      &lt;/section&gt;
  
  MyFunction(){
  var img = document.getElementById("image");
  img.rotate(20*Math.PI/180);
  }
  </code></pre>