Side navigation
#12544 closed bug (notabug)
Opened September 15, 2012 07:39PM UTC
Closed September 15, 2012 08:46PM UTC
Width property
Reported by: | chrst96@gmail.com | Owned by: | chrst96@gmail.com |
---|---|---|---|
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.
Attachments (0)
Change History (5)
Changed September 15, 2012 07:51PM UTC by comment:1
owner: | → chrst96@gmail.com |
---|---|
status: | new → pending |
Changed September 15, 2012 08:09PM UTC by comment:2
status: | pending → new |
---|
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 comment:3
status: | new → pending |
---|
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: | pending → new |
---|
This is the link for the code http://jsfiddle.net/TtLFC/
Changed September 15, 2012 08:46PM UTC by comment:5
resolution: | → notabug |
---|---|
status: | new → closed |
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.
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.