JQuery uses the Css Display
value under the hood of the simple show() and hide() functions. The following Html includes three buttons each wrapped in a span tag, and all three span tags placed in a parent div container. On page load the span tags are hidden using JQuery hide() and at some point later on they are displayed using the show() function. The Html is now in the following state with the span tag having received the style value display:block.
<div style="text-align:right; width:100%;">
<span style="display:block">
<input type="button" value="Button1" />
</span>
<span style="display:block">
<input type="button" value="Button2" />
</span>
<span style="display:block">
<input type="button" value="Button3" />
</span>
</div>
In Firefox (3.5) the span elements appear stacked vertically on top of each other, whereas in IE they appear inline. I would have expected the latter in both browsers because I thought that the default layout for span tags was inline.
If I manually change the style from display:block.
to display:inline.
it looks correct in Firefox. Essentially, when showing an element JQuery is using a value for display
that is not always valid. Adding display:block.
is enough to show the element but not enough to show it with the inline layout I require.
So, to my questions...
- Is this a known issue with JQuery? I am using JQuery 1.2.6.
- Has anyone experienced this problem before, and how did you get around it?