Bug Tracker

Modify

Ticket #10741 (closed bug: duplicate)

Opened 20 months ago

Last modified 20 months ago

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:
Blocking: Blocked by:

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

comment:1 Changed 20 months 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 20 months ago by rwaldron

  • Status changed from new to closed
  • Resolution set to duplicate

Thanks for the dup!

comment:3 Changed 20 months ago by rwaldron

Duplicate of #10416.

comment:4 Changed 20 months 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);

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.