Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#10741 closed bug (duplicate)

jQuery.css(this, 'display') on a detached element is inconsistent across browsers

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

Description

in Chrome and IE, jQuery.css(this, 'display') reports on a detached element. However, in FF (I tested it on 3.6), it reports the default value of an element, such as 'block' for div.

I have a detached div#files, and in CSS it is defined as #files(display:table-cell)

The result is that, in jQuery's hide() function, jQuery._data( this[i], "olddisplay", display ) stores 'block' for a detached div, and so upon .show() it would become a block element. What I wanted is to retain its CSS style defined in the CSS file.

Change History (4)

comment:1 Changed 12 years ago by anonymous

http://jsfiddle.net/davidtong/gxNeD/

Try it in Chrome/IE and then in FF. The red console div should be empty in Chrome/IE, but in FF it says 'block'

comment:2 Changed 12 years ago by Rick Waldron

Resolution: duplicate
Status: newclosed

Thanks for the dup!

comment:3 Changed 12 years ago by Rick Waldron

Duplicate of #10416.

comment:4 Changed 12 years ago by anonymous

My workaround:

var old_display = j_div.css('display'); cache custom display value (e.g. display:table-cell)

j_div.detach().hide(); upon detach, j_div.css('display') returns 'block' even if we set display:table-cell in the CSS

$j._data(j_div[0], "olddisplay", old_display);

Note: See TracTickets for help on using tickets.