JavaScript DHTML/jQuery/slideUp
Содержание
- 1 Animates all divs to slide up, completing the animation within 400 milliseconds.
- 2 Animates all form controls to slide up
- 3 Click to slide up
- 4 Slide up a DIV tag
- 5 Slide up callback
- 6 Slide up fast
- 7 Slide up form controls
- 8 Slide up in milliseconds
- 9 Slide up slowly
- 10 slideUp(speed, callback): Only the height is adjusted for this animation
Animates all divs to slide up, completing the animation within 400 milliseconds.
<html>
<head>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(document.body).click(function () {
if ($("div:first").is(":hidden")) {
$("div").show("slow");
} else {
$("div").slideUp();
}
});
});
</script>
</head>
<body>
<body>
Click me!
<div>asdf</div>
<div>asdf</div>
<div>asdf</div>
<div>asdf</div>
<div>asdf</div>
</body>
</html>
Animates all form controls to slide up
<html>
<head>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function () {
$(this).parent().slideUp("slow", function () {
$("#msg").text($("button", this).text() + " has completed.");
});
});
});
</script>
</head>
<body>
<body>
<button>Hide One</button>
<input type="text" value="One" />
<button>Hide Two</button>
<input type="text" value="Two" />
<button>Hide Three</button>
<input type="text" value="Three" />
<div id="msg"></div>
</body>
</html>
Click to slide up
<html>
<head>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("p").click(function () {
$(this).slideUp();
});
});
</script>
</head>
<body>
<body>
<p>asdf</p>
<p>asdf</p>
</body>
</html>
Slide up a DIV tag
<html>
<head>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("div").click(function () {
$("div").slideUp();
});
});
</script>
</head>
<body>
<body>
<div>Click me</div>
</body>
</html>
Slide up callback
<html>
<head>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function () {
$(this).parent().slideUp("slow", function () {
alert("done");
});
});
});
</script>
</head>
<body>
<body>
<div>Click me<button>button</button></div>
</body>
</html>
Slide up fast
<html>
<head>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("div").click(function () {
$("div").slideUp("fast");
});
});
</script>
</head>
<body>
<body>
<div>Click me</div>
</body>
</html>
Slide up form controls
<html>
<head>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function () {
$(this).parent().slideUp("slow", function () {
alert("done");
});
});
});
</script>
</head>
<body>
<body>
<div>Click me<button>button</button></div>
</body>
</html>
Slide up in milliseconds
<html>
<head>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("div").click(function () {
$("div").slideUp(2000);
});
});
</script>
</head>
<body>
<body>
<div>Click me</div>
</body>
</html>
Slide up slowly
<html>
<head>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("div").click(function () {
$("div").slideUp("slow");
});
});
</script>
</head>
<body>
<body>
<div>Click me</div>
</body>
</html>
slideUp(speed, callback): Only the height is adjusted for this animation
<html>
<head>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(document.body).click(function () {
if ($("div:first").is(":hidden")) {
$("div").show("slow");
} else {
$("div").slideUp();
}
});
});
</script>
</head>
<body>
<body>
Click me!
<div>asdf</div>
<div>asdf</div>
<div>asdf</div>
<div>asdf</div>
<div>asdf</div>
</body>
</html>