SPAN element becomes block level on show() in jQuery

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; } #span { display:none; } in demo 1 and span { display:none; } 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


This issue has been identified as a bug. The ticket is here:
http://bugs.jquery.com/ticket/8099

链接地址: http://www.djcxy.com/p/4590.html

上一篇: 如何在本地和远程创建新分支? GIT

下一篇: SPAN元素在jQuery的show()上成为块级别