Định nghĩa và sử dụng .slideUp() rong jQuery

.slideUp(): Ẩn các thành phần phù hợp với hiệu ứng chuyển động trượt (slide).

Cấu trúc .slideUp() rong jQuery

Đã được thêm vào từ phiên bản 1.0

.slideUp(Độ bền)

Độ bền có thể bằng số hoặc bằng chữ: slow, fast.

$('p').slideUp(300);
$('p').slideUp(fast);
.slideUp(Độ bền,function(){...})

Độ bền có thể bằng số hoặc bằng chữ: slow, fast.

$('p').slideUp(300,function(){
    $('span').fadeIn(100);
});

Đã được thêm vào từ phiên bản 1.4.3

.slideUp(Độ bền,'easing')

Độ bền có thể bằng số hoặc bằng chữ: slow, fast.

Easing có thể sử dụng swing hoặc linear

$('p').slideUp(300,'swing');
.slideUp(Độ bền,'easing',function(){...})

Độ bền có thể bằng số hoặc bằng chữ: slow, fast.

Easing có thể sử dụng swing hoặc linear

$('p').slideUp(300,'swing',function(){
    $('span').fadeIn(100);
});

.slideUp(Độ bền)

Html viết:

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Tiêu đề</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<style>
div {
    background-color: blue;
    display: block;
    float: left;
    margin-right: 20px;
    height: 100px;
    width: 150px;
}
p {
    clear: both;
}
</style>
<script>
$(function(){
    $('button').click(function(){
        $('.test03').slideUp(2000);
        $('.test02').slideUp('slow');
    });
});
</script>
</head>

<body>
<p><button>Click</button></p>
<div class="test03">slideUp(2000)</div>
<div class="test02">slideUp(slow)</div>
</body>
</html>

Hiển thị trình duyệt:

Click vào button để thấy hiệu ứng.

.slideUp(Độ bền,'easing')

Html viết:

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Tiêu đề</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<style>
div {
    background-color: blue;
    display: block;
    float: left;
    margin-right: 20px;
    height: 100px;
    width: 150px;
}
p {
    clear: both;
}
.visible {
    background-color: red;
    display: block!important;
}
</style>
<script>
$(function(){
    $('button').click(function(){
        $('.swing').slideUp(2000,'swing');

        $('.linear').slideUp(2000,'linear');
    });
});
</script>
</head>

<body>
<p><button>Click</button></p>
<div class="swing">slideUp swing</div>
<div class="linear">slideUp linear</div>
</body>
</html>

Hiển thị trình duyệt:

Click vào button để thấy hiệu ứng.

.slideUp(Độ bền,'easing',function(){...})

Html viết:

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Tiêu đề</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<style>
div {
    background-color: blue;
    display: block;
    float: left;
    margin-right: 20px;
    height: 100px;
    width: 150px;
}
p {
    clear: both;
}
.visible {
    background-color: red;
    display: block!important;
}
</style>
<script>
$(function(){
    $('button').click(function(){
        $('.swing').slideUp(2000,'swing',function(){
            $(this).addClass('visible').text('Nội dung mới');
        });

        $('.linear').slideUp(2000,'linear',function(){
            $(this).addClass('visible').text('Nội dung mới');
        });
    });
});
</script>
</head>

<body>
<p><button>Click</button></p>
<div class="swing">slideUp swing</div>
<div class="linear">slideUp linear</div>
</body>
</html>

Hiển thị trình duyệt:

Click vào button để thấy hiệu ứng, sau khi hoàn thành hiệu ứng sẽ hiển thị nội dung bên trong function.

Viết câu trả lời

Drop Images

0 Bình luận