CSS で display: inline; にする div があります。
ただし、jQuery の表示/非表示を使用すると、ブロック/なしに変更されます。
これを防ぎ、jQueryが表示するときにインラインで表示を維持するにはどうすればよいですか?
CSS で display: inline; にする div があります。
ただし、jQuery の表示/非表示を使用すると、ブロック/なしに変更されます。
これを防ぎ、jQueryが表示するときにインラインで表示を維持するにはどうすればよいですか?
わかりません。
しかし、あなたが簡単にできることは、
$('.your-element).css({'display':'inline'});
.show() の代わりに。
.hide() は通常どおり使用できます。賢いことは今のところ思いつきません。
According to the jQuery docs:
If an element has a display value of inline, then is hidden and shown, it will once again be displayed inline.
Is something else going on?
Demo: http://jsfiddle.net/jtbowden/JdJFJ/
Here is the code snippet from the source:
if ( display !== "none" && !jQuery._data( elem, "olddisplay" ) ) {
jQuery._data( elem, "olddisplay", display );
}
Basically, it stores the original display
in internal data, which is restored on show()
. Similar, but different, code exisited all the way back in jQuery 1.0.
@ benhowdle89これはjQueryですでに可能になっているようです。どのバージョンを使用していますか?