Ticket #12243 (closed bug: fixed)
$("col").width() returns 0
| Reported by: | akorchev@… | Owned by: | mikesherov |
|---|---|---|---|
| Priority: | low | Milestone: | None |
| Component: | dimensions | Version: | 1.8.0 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
It seems that width(), outerWidth() and css("width") no longer work for col elements. Zero is always returned. Here is the repro: http://jsbin.com/ilejan/1/edit
Change History
comment:1 Changed 9 months ago by dmethvin
- Owner set to mikesherov
- Priority changed from undecided to low
- Status changed from new to assigned
- Component changed from unfiled to dimensions
comment:3 Changed 9 months ago by nicola@…
I have a similar issue: http://jsfiddle.net/eZLLU/
If you remove the div tag or if you use jQuery 1.7.2, width is reported correctly.
comment:4 Changed 9 months ago by mikesherov
nicola: http://stackoverflow.com/questions/1827965/is-putting-a-div-inside-an-anchor-ever-correct While jQuery worked in this case in 1.7.2, it was accidental. It worked because jQuery was changing the style of the a tag to display: block momentarily. This causes undesired and incorrect results elsewhere. Removing the div makes it work again, because you once again have valid HTML.
Long story short: use valid HTML and it works fine.
Fix for col coming shortly.
comment:5 Changed 9 months ago by Mike Sherov
- Status changed from assigned to closed
- Resolution set to fixed
Fix #12243, $("col").width() should return the column's width. Close gh-916.
Changeset: 670e3ff040b0a7164f36a3c5e07214420b8b09f4
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Mike, could you take a look at this?