how to get bounding box for div element in jquery

后端 未结 3 1515
后悔当初
后悔当初 2021-01-30 13:14

i want to calculate bounding box for div element via jquery/javascript.

i tried like this .

//Left side of box 
document.getElementById(\"myElement\").of         


        
3条回答
  •  情书的邮戳
    2021-01-30 13:23

    You can get the bounding box of any element by calling getBoundingClientRect

    var rect = document.getElementById("myElement").getBoundingClientRect();
    

    That will return an object with left, top, width and height fields.

提交回复
热议问题