Home  >  Q&A  >  body text

Get the *two* height values ​​of the canvas?

I'm trying to get the two height values ​​for this canvas.

<canvas width="886" height="792" style="display: block; opacity: 0.5; width: 834px; height: 746px;"></canvas>

I know, I can access one of the styles using canvas.style.height;, but how do I get the other one?

please help. kind regards.

P粉604848588P粉604848588222 days ago1427

reply all(1)I'll reply

  • P粉360266095

    P粉3602660952024-04-06 00:07:45

    You can get other heights simply by accessing the height property of the canvas:

    var canvas = document.querySelector("canvas");
    var height = canvas.height;
    console.log(height);

    reply
    0
  • Cancelreply