I created two demos:
Demo 1: http://jsfiddle.net/DqvTa/7/
Demo 2: http://jsfiddle.net/DqvTa/8/
The demos are almost identical. The only difference is that I set #span { display:none; }
in demo 1 and span { display:none; }
in demo 2.
Could someone explain why the SPAN element - in demo 2 - becomes a block-level element?
My assumption is that (during show()
) jQuery internally creates a SPAN element to check whether it is naturally an inline or block-level element. But since I set all SPANs to display:none
in demo 2, jQuery is unable to determine that.
btw the ticket is here: http://bugs.jquery.com/ticket/8099
That's a bug, right.
But you can do $('span').css('display', 'inline');
rather than $('span').show();
This is because, .show(), is like a display block except that the display property is restored to whatever it was initially.
jQuery use a propertry called olddisplay in the node that you modify with show (you can see it with FireQuery), if you modify the box model of the span, (not the #span) jquery dont recognice the correct old display mode of the node
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With