Skip to main content

Bug Tracker

Side navigation

#12544 closed bug (notabug)

Opened September 15, 2012 07:39PM UTC

Closed September 15, 2012 08:46PM UTC

Width property

Reported by: Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.0
Keywords: Cc:
Blocked by: Blocking:

jQuery not reading the image width. It will only return a function as a value or 0.

Attachments (0)
Change History (5)

Changed September 15, 2012 07:51PM UTC by mikesherov comment:1

owner: →
status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.

Additionally, be sure to test against the jQuery git("edge") version to ensure the issue still exists. To get you started, use this boilerplate: Open the link and click to "Fork" (in the top menu) to get started.

Changed September 15, 2012 08:09PM UTC by comment:2

status: pendingnew

I have tested it on the jsFiddle and the bug is still occurring. I am trying to retrieve the width and height of and image that its src attribute is being set by jquery as well. I am using this algorithm image_width = $('.gallery_img').width; in order to get the width in px so I can use it in my algorithm.

Changed September 15, 2012 08:27PM UTC by mikesherov comment:3

status: newpending

OK, please provide the link to the jsfiddle you created so we could see what you were doing and potentially fix.

Changed September 15, 2012 08:31PM UTC by comment:4

status: pendingnew

This is the link for the code

Changed September 15, 2012 08:46PM UTC by ajpiano comment:5

resolution: → notabug
status: newclosed

jQuery objects don't have width or height properties, they have width and height *methods.* You have to call .width() or .height(), not access the .width and .height properties which are, in fact, functions. Furthermore, you have to wait until an image has loaded in order to measure its width and height.

I am not entirely sure that this fiddle achieves the desired behaviour but it doesn't appear that there is a jQuery bug in play here:

If you need more help please head to IRC or ask on the forums.