JavaScript DHTML/jQuery/slideToggle
Содержание
Fast slide toggle
<source lang="html4strict">
<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).slideToggle("fast"); });
}); </script> </head> <body> <body>
Click me<button>button</button>
</body>
</html>
</source>
Slide animation
<source lang="html4strict">
<html>
<head> <script type="text/javascript" src="js/jquery-1.3.2.js"></script> <script type="text/javascript"> $(document).ready(function(){ function animateIt() { $("#mover").slideToggle("slow", animateIt); } animateIt(); }); </script> <style> div { background:yellow; width:80px; height:80px; margin:5px; float:left; } </style> </head> <body>
</body>
</html>
</source>
Slide toggle and function
<source lang="html4strict">
<html>
<head> <script type="text/javascript" src="js/jquery-1.3.2.js"></script> <script type="text/javascript"> $(document).ready(function(){ function animateIt() { $("#mover").slideToggle("slow", animateIt); } animateIt(); }); </script> <style> div { background:yellow; width:80px; height:80px; margin:5px; float:left; } </style> </head> <body>
</body>
</html>
</source>
Slide toggle button
<source lang="html4strict">
<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).slideToggle(); });
}); </script> </head> <body> <body>
Click me<button>button</button>
</body>
</html>
</source>
Slide toggle callback
<source lang="html4strict">
<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).slideToggle("slow",function () { alert("done"); }); });
}); </script> </head> <body> <body>
Click me<button>button</button>
</body>
</html>
</source>
Slide toggle in milliseconds
<source lang="html4strict">
<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).slideToggle(2000); });
}); </script> </head> <body> <body>
Click me<button>button</button>
</body>
</html>
</source>
Slide toggle slow
<source lang="html4strict">
<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).slideToggle("slow"); });
}); </script> </head> <body> <body>
Click me<button>button</button>
</body>
</html>
</source>
slideToggle(speed, callback): height is adjusted
<source lang="html4strict">
<html>
<head> <script type="text/javascript" src="js/jquery-1.3.2.js"></script> <script type="text/javascript"> $(document).ready(function(){
$("button").click(function () { $("p").slideToggle("slow"); });
}); </script> </head> <body> <body> <button>Toggle</button>
This is the paragraph.
</body>
</html>
</source>