jQuery fadeOut()方法,淡出

fadeOut()语法

$(selector).fadeOut(speed, callback)

fadeOut()语法解析

jQuery中fadeOut()方法,可以用于淡出隐藏之前为显示状态的HTML元素。

fadeOut()参数

参数描述
speed可选,指定淡出的速度,单位为毫秒,或slow、fast等预定义值。
callback可选,回调函数。

fadeOut()实例代码

如下代码,通过id选择器,将一个原本显示的div元素淡出隐藏:

<div style="width:100%;height:50%;background-color:green;" id="div1"></div>

<button id="test" type="button">确定</button>

<script>
function fadeOutAlertSomething(){
  alert("hello!")
}
$("#test").click(function(){
  $("#div1").fadeOut(1000, fadeOutAlertSomething())
})
</script>

免责声明:内容仅供参考,不保证正确性!


全栈前端 / jQuery教程 :






Copyright © 2022-2024 笨鸟工具 x1y1z1.com All Rights Reserved.