How could I detect if an element has padding applied to it?
So something like:
if($('div.MiddleColumn') has padding of 5px) {
do something
}
else
{
do something else
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This will return the total horizontal padding of your element :
.innerWidth()returns the same value as.width(), plus the padding. Sohz_paddingwill be > 0 if$("el")has any padding.The interesting thing here is that you will have the computed styles, which might be different from those in the stylesheet.
More on .innerWidth() and .width().
Use
.outerWidth()if you want to include borders, and.outerWidth(true)to include margin.And there are obviousy the same methods for the height.