且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery如何获取Element的边距和填充?

更新时间:2021-11-08 23:06:44

根据 jQuery文档,速记CSS属性是不支持.

According to the jQuery documentation, shorthand CSS properties are not supported.

根据总填充"的含义,您可以执行以下操作:

Depending on what you mean by "total padding", you may be able to do something like this:

var $img = $('img');
var paddT = $img.css('padding-top') + ' ' + $img.css('padding-right') + ' ' + $img.css('padding-bottom') + ' ' + $img.css('padding-left');