0

私はjQueryプラグインを書いていますが、これをやろうとしています:

$(this).height>=options.maxHeight ? 
$(this).css({overflow:"auto"}) : 
$(this).css({overflow:"hidden"})

ただし、機能していません。以前に JavaScript でこのメソッドを使用したことがあります。

これは、可能な限り小さなコードを使用しようとしていただけです。

if($(this).height()>=options.maxHeight)
{
     $(this).css({overflow:"auto"});
}
else
{
     $(this).css({overflow:"hidden"});
}
4

1 に答える 1

1

次のように変更します。

$(this).height() >= options.maxHeight ? 
$(this).css({overflow:"auto"}) : 
$(this).css({overflow:"hidden"})

を忘れまし().height()

これを使用することもできます:

$(this).css({overflow: $(this).height() >= options.maxHeight ? 'auto' : 'hidden'});
于 2012-02-01T01:23:32.560 に答える