jQuery效果显示show方法


在最简单的形式中, .show() 立即显示匹配的元素,没有动画。例如:

$(".myclass").show();

将显示其类为_myclass的_所有元素。可以使用任何jQuery选择器。

但是,此方法不会覆盖CSS样式中的!important ,例如display: none !important

.show()作为动画方法

由于其选项, .show() 可以同时为匹配元素的宽度,高度和不透明度设置动画。

  • 持续时间可以以毫秒为单位,或者使用文字慢(600毫秒)和快速(200毫秒)。例如:
$("#myobject").show("slow");
  • 可以指定在动画完成后调用函数,每个匹配元素调用一次。例如
$("#title").show( "slow", function() {
    $("p").show("fast");
 });
  • More options exist, please refer to the official website for further details.

.slideDown() method

This method animates the height of the matched elements. This causes lower parts of the page to slide down, making way for the revealed items.

$(".myclass").slideDown(); //will expand the element with the identifier myclass for 400 ms.
$(".myclass").slideDown(1000); //will expand the element with the identifier myclass for 1000 ms.
$(".myclass").slideDown("slow"); //will expand the element with the identifier myclass for 600 ms.
$(".myclass").slideDown("fast"); //will expand the element with the identifier myclass for 200 ms.

更多jQuery教程

学习更多jQuery教程