0

CSS で display: inline; にする div があります。

ただし、jQuery の表示/非表示を使用すると、ブロック/なしに変更されます。

これを防ぎ、jQueryが表示するときにインラインで表示を維持するにはどうすればよいですか?

4

3 に答える 3

0

わかりません。

しかし、あなたが簡単にできることは、

$('.your-element).css({'display':'inline'});

.show() の代わりに。

.hide() は通常どおり使用できます。賢いことは今のところ思いつきません。

于 2012-04-17T22:02:04.737 に答える
0

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.

于 2012-04-17T22:06:41.177 に答える
0

@ benhowdle89これはjQueryですでに可能になっているようです。どのバージョンを使用していますか?

于 2012-04-17T22:07:31.663 に答える