gpt4 book ai didi

javascript - 如何使用jquery获取div的宽度?

转载 作者:太空宇宙 更新时间:2023-11-03 19:39:23 25 4
gpt4 key购买 nike

像这样设置了两列

.left_inside_tab{ float: left; padding-left: 25px; width: 45%; }
.right_inside_tab{ float: right; width: 45%;}

我试着像这样获得宽度

console.log ($('.left_inside_tab').width());
console.log ($('div.left_inside_tab').width());

都给

结果为 45。问题是 45 不是以像素为单位的百分比

我做错了什么?

问候

最佳答案

代替 .width() 使用 .outerWidth()

Heres the jQuery Link

关于javascript - 如何使用jquery获取div的宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6661591/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com