Tam*_*ami 1 javascript jquery code-cleanup
var ProdWidth = Math.abs(parseInt(Product.css('width')))
+ Math.abs(parseInt(Product.css('marginLeft')))
+ Math.abs(parseInt(Product.css('marginRight')))
+ Math.abs(parseInt(Product.css('paddingLeft')))
+ Math.abs(parseInt(Product.css('paddingRight')));
Run Code Online (Sandbox Code Playgroud)
这适用于提出元素的总宽度,包括填充和边距,但它的愚蠢.我应该怎么做?
看看outerWidth()酒店.它获取元素的宽度及其填充,边框等.
将其第一个参数设置为true包括边距.
var ProdWidth = Product.outerWidth(true);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
509 次 |
| 最近记录: |