Bug Tracker

Opened 11 years ago

Closed 11 years ago

#12544 closed bug (notabug)

Width property

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

Description

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

Change History (5)

comment:1 Changed 11 years ago by mikesherov

Owner: set to chrst96@…
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: http://jsfiddle.net/FrKyN/. Open the link and click to "Fork" (in the top menu) to get started.

comment:2 in reply to:  1 Changed 11 years ago by chrst96@…

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.

comment:3 Changed 11 years ago by mikesherov

Status: newpending

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

comment:4 Changed 11 years ago by chrst96@…

Status: pendingnew

This is the link for the code http://jsfiddle.net/TtLFC/

comment:5 Changed 11 years ago by ajpiano

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: http://jsfiddle.net/TtLFC/1/.

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

Note: See TracTickets for help on using tickets.