个性化阅读
专注于IT技术分析

jQuery fadeIn()

jQuery fadeIn()方法用于淡入元素。

句法:

$(selector).fadein();
$(selector).fadeIn(speed, callback); 
$(selector).fadeIn(speed, easing, callback);

速度:这是一个可选参数。它指定延迟的速度。其可能的值是慢, 快和毫秒。

缓动:指定用于过渡的缓动功能。

callback:这也是一个可选参数。它指定在fadein()效果完成后要调用的函数。

让我们以一个示例来演示jQuery fadeIn()的效果。

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $("#div1").fadeIn();
        $("#div2").fadeIn("slow");
        $("#div3").fadeIn(3000);
    });
});
</script>
</head>
<body>
<p>See the fadeIn() method example with different parameters.</p>
<button>Click to fade in boxes</button><br><br>
<div id="div1" style="width:80px;height:80px;display:none;background-color:red;"></div><br>
<div id="div2" style="width:80px;height:80px;display:none;background-color:green;"></div><br>
<div id="div3" style="width:80px;height:80px;display:none;background-color:blue;"></div>
</body>
</html>

立即测试

输出:

请参见带有不同参数的fadeIn()方法示例。

单击以淡入框

赞(0)
未经允许不得转载:srcmini » jQuery fadeIn()

评论 抢沙发

评论前必须登录!