Is this inline style or css file style with jquery.css ()

I want to check the correct fill value of a div element. I am using jquery .css () method:

$('div').css('padding-right'); 

It works. Now I need to know where it came from. This can be with the built-in defenition:

 <div style="padding-right: 100px;"> 

or it can be written in an external css file (or <style></style> ):

 div { padding-right: 100px; } 

Thanks!

+5
source share
3 answers

According to css () documentation

Get style properties computed

and

Please note that the style of the calculated element may not be the same as the value specified for this element in the style sheet. For example, computed dimension styles are almost always pixels, but they can be indicated as em, ex, px, or% in the stylesheet. Different browsers can return CSS color values โ€‹โ€‹that are logically but not textual equal, for example, #FFF, #ffffff and rgb (255, 255, 255).

Therefore, at the end, whether from an inline style or style sheet, this is a calculated style.

+4
source

Try using the developer tools in your browser as you see fit. Right-click on the div element โ†’ check (or similar) and look at the CSS for that element. Find your padding-right and it should show you the source of this rule.

+1
source

You can check if your element has inline styles testing the style property for the DOM element

 $("div")[0].style 
+1
source

All Articles