title: Add Style on image object using JavaScript in Canvas
body: <p>I'm trying to add z-index on the image. I also used setAttribute but style not working. Please figure out the issue</p>
  
  <pre><code>// Hero image
  var heroReady = false;
  var heroImage = new Image();
  heroImage.onload = function () {
      heroReady = true;
  };
  
  heroImage.setAttribute("src", "img/car.png");
  heroImage.setAttribute("style", "z-index:5;");
  </code></pre>