Set canvas dimensions

by greatCar

HTML

<div id="parent" style="background-color:blue;width:140px;height:20px">
        <canvas id="theCanvas" style="background-color: transparent;">
        </canvas>
    </div>

JavaScript

var canvas = document.getElementById("theCanvas");
var parent = document.getElementById("parent");
canvas.width = parent.offsetWidth;
canvas.height = parent.offsetHeight;

/**$(document).ready(function() {
  var canvas = document.getElementById("theCanvas");
  canvas.width = $("#parent").width();
  canvas.height = $("#parent").height();
});**/