Just wondering – how using jQuery – I can get an elements formatted total padding and margin etc ? i.e. 30px 30px 30px 30px or 30px 5px 15px 30px etc
I tried
var margT = jQuery('img').css('margin');
var bordT = jQuery('img').css('border');
var paddT = jQuery('img').css('padding');
But this doesn't work ? http://jsfiddle.net/q7Mra/
Best Answer
Check the jQuery API docs for information on each:
Here's the edited jsFiddle showing the result.
You can perform the same type of operations for the Height to get its margin, border, and padding.