slideUp()是一个内置方法jQuery用于隐藏选定的元素。
用法:
$(selector).slideUp(speed);
参数:它接受一个可选参数“speed”,该参数指定效果持续时间的速度。
jQuery 示例展示 slideUp() 方法的用法原理:
示例 1:在下面的代码中,没有参数传递给该方法。
HTML
<!DOCTYPE html>
<html>
<head>
<script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<!--jQuery code to show the working of this method-->
<script>
$(document).ready(function () {
$(".btn1").click(function () {
$("p").slideUp();
});
});
</script>
<style>
div {
width: 300px;
height: 100px;
padding: 20px;
border: 2px solid green;
}
</style>
</head>
<body>
<div>
<p>This paragraph will get hide.</p>
<!-- click on this button -->
<button class="btn1">Slide up</button>
</div>
</body>
</html>
输出:
示例 2:在下面的代码中,加速参数传递给此方法。
HTML
<!DOCTYPE html>
<html>
<head>
<script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<!--jQuery code to show the working of this method-->
<script>
$(document).ready(function () {
$(".btn1").click(function () {
$("p").slideUp(3000);
});
});
</script>
<style>
div {
width: 300px;
height: 100px;
padding: 20px;
border: 2px solid green;
}
</style>
</head>
<body>
<div>
<p>This paragraph will get hide.</p>
<!-- click on this button -->
<button class="btn1">Slide up</button>
</div>
</body>
</html>
输出:
相关用法
- JQuery slideUp()用法及代码示例
- JQuery slideDown()用法及代码示例
- JQuery slideToggle()用法及代码示例
- JQuery slice()用法及代码示例
- JQuery show()用法及代码示例
- JQuery scroll()用法及代码示例
- JQuery scrollLeft()用法及代码示例
- JQuery scrollTop()用法及代码示例
- JQuery select()用法及代码示例
- JQuery serialize()用法及代码示例
- JQuery serializeArray()用法及代码示例
- JQuery siblings()用法及代码示例
- JQuery size()用法及代码示例
- JQuery stop()用法及代码示例
- JQuery submit()用法及代码示例
- JQuery sub()用法及代码示例
- JQuery andSelf()用法及代码示例
- JQuery change()用法及代码示例
- JQuery each()用法及代码示例
- JQuery end()用法及代码示例
- JQuery fadeOut()用法及代码示例
- JQuery height()用法及代码示例
- JQuery innerHeight()用法及代码示例
- JQuery keydown()用法及代码示例
- JQuery keypress()用法及代码示例
注:本文由纯净天空筛选整理自kundankumarjha大神的英文原创作品 jQuery slideUp() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。