jQuery fadeIn()方法,淡入
fadeIn()语法
$(selector).fadeIn(speed, callback)
fadeIn()语法解析
jQuery中fadeIn()方法,可以用于淡入显示已经隐藏的HTML元素。
fadeIn()参数
参数 | 描述 |
---|---|
speed | 参数可选,指定淡入的速度,比如以毫秒为单位,或预定义的值slow、fast等。 |
callback | 可选,回调函数。 |
fadeIn()实例代码
如下代码,通过class选择器,将一个原本隐藏的div元素设置淡入显示:
<div hidden style="width:100%;height:50%;background-color:green;" class="div1"></div>
<button id="test" type="button">确定</button>
<script>
function fadeInAlertSomething(){
alert("hello!")
}
$("#test").click(function(){
$(".div1").fadeIn(500, fadeInAlertSomething())
})
</script>
免责声明:内容仅供参考,不保证正确性!