jq获取元素的宽,高

精确到小数点:

1.

console.log(window.getComputedStyle(document.getElementById("test")));

2.

$("#test")[0].getBoundingClientRect()

不精确到小数点

1.获取内容宽度

$('.schoolMajorLeftTitle span').eq(i).width()

2.content+padding

$('.schoolMajorLeftTitle span').eq(i).outerWidth()

$("#test")[0].getBoundingClientRect()

原文地址:https://www.cnblogs.com/SunShineM/p/7919957.html