Skip to main content

Bug Tracker

Side navigation

#984 closed bug (invalid)

Opened February 20, 2007 02:23PM UTC

Closed February 23, 2007 04:02AM UTC

Last modified March 15, 2012 06:06PM UTC

$(element).width() & $(element).height() functions return incorrect values

Reported by: elemerz Owned by:
Priority: minor Milestone: 1.1.2
Component: core Version: 1.1.1
Keywords: Layout Manager Cc:
Blocked by: Blocking:

$(element).width() & $(element).height() functions return incorrect values.

I rewrote the prototype 1.5.0 -based [RUZEE layout Manager|] for jQuery.

I needed to get the dimensions of an element, in form of a hash like: {width:widthValue,height:heightValue}. I used: {width:$(element).width(), height:$(element).height()} in the jQuery version. I noticed that these two functions (width(), and height()) do not return the same values like Element.getDimensions(element) used by prototype.

My jQuery -based rewritten version of the above mentioned LayoutManager does not render correctly because of these differences.

To see in action what I'm talking about, set the useJQueryDimensions variable inside of lm.jquery.js file in the attachment.

Thanx in advance,


In the attachment you can find

Attachments (1)
  • (18.0 KB) - added by elemerz February 20, 2007 02:24PM UTC.

    Layout Manager based on jQuery.

Change History (4)

Changed February 21, 2007 08:06AM UTC by alexo comment:1

This ticket is related to core component, not ajax...

Changed February 22, 2007 09:45PM UTC by john comment:2

component: ajaxcore
priority: majorminor

I'm not entirely sure what I'm supposed to be seeing - but I did notice that you subtract the padding and border widths from the height/width - jQuery already does this. The .height() and .width() returned by jQuery do not include those numbers, and are stable across browsers.

Additionally, you may want to look into the Dimensions plugin, which will reduce the size of your plugin by about 90%, it looks like.

Changed February 23, 2007 04:02AM UTC by brandon comment:3

resolution: → invalid
status: newclosed

As John mentioned, the jQuery width and height methods return the actual computed CSS width and height. If you want the offset width (includes padding and border) you should use the dimensions plugin outerWidth method (it also accounts for if an element is display: none).

Also just a note ... you can pass the css method numbers and it will append the "px" for you.

Changed April 22, 2011 11:06AM UTC by anonymous comment:4





'' ==

'' ==