Why does height() return a completely even number regardless of window size in jQuery? -
I'm trying to set the height of a specific element on my page. I have not set the height in the CSS, and regardless of the size of the window, the following code always gives the integer '100'
var img_h = $ ("# compare_view"). Height (); Console.log (img_h);
When I try a different div element on the page, it gives the integer '20'.
It is despite the fact that when I develop the Chrome tools in the element, it shows me height of 415 px or some other height in pixels (which is correct). Edit: Okay ... It seems I have come to know that this is because it is the height of 100% for the basic element, and because there are 5 divisions within the parent, Each has a height of 20%, so I think my new question is ... how do I return it to PX, and not set the percentage in pixels?
Edit 2: Okay .... This is true I instead edit it using the following code instead of var img_h = $ ("# compare_view"). Css ('height'); Console.log (img_h);
and it has been returned '100px'
, so it is returning the value of height in pixels, but it is not clear if it is correct. That's why I'm still at the original place - that is not sure why he is returning those weird numbers. <3 px> Edit 3: Here's the relevant CSS - this is the only segment that is related to this div ID:
#compare_view # compv-navbar {font-weight: bold; Background: #F9F4C 0; Height: 23px; Width: 220 pixels; Border: 1px solid # c97d7d; Word-spacing: 0 pixels; Letter-spacing: 2px; Margin: 0 15 px 0; / * Above, Right, Bottom, Left * / Padding: 5px 0px 7px 0px; / * Top, right, bottom, left * /}
Note that this is not specifically for div id = "compare_view", but rather a child of comparison_view.
The comparison_view has no height in the stylesheet across my site.
height ()
method of jQuery
Comments
Post a Comment