Getting the actual, floating-point width of an element

后端 未结 2 1697
我在风中等你
我在风中等你 2020-11-30 03:40

I\'m using jQuery (v1.7.1) and I need to get the absolute, floating-point width of an element, but all of jQuery\'s width methods seem to be rounding-off the value of the wi

2条回答
  •  死守一世寂寞
    2020-11-30 04:25

    Try this:

    var element = document.getElementById("a");
    alert(window.getComputedStyle(element).width);
    

    Updated fiddle: http://jsfiddle.net/johnkoer/Z2MBj/18/

提交回复
热议问题