jQuery slideUp()方法,向上滑动

slideUp()语法

$(selector).slideUp(speed, callback)

slideUp()语法解析

jQuery中slideUp()方法,用于向上滑动隐藏原本为显示状态的元素。

slideUp()参数

参数描述
speed向上滑动隐藏的速度,单位为毫秒,或slow、fast等预定义值。
callback回调函数。

slideUp()实例代码

如下代码,通过类class选择器,将显示的div元素向上滑动隐藏:

<button id="test" type="button">点击该按钮,向上滑动隐藏div元素</button>
<div style="width:100%;height:50%;background-color:green;" class="div1"></div>


<script>
function slideUpAlertSomething(){
  alert("hello!")
}
$("#test").click(function(){
  $(".div1").slideUp(500, slideUpAlertSomething())
})
</script>

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


全栈前端 / jQuery教程 :






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