Jquery8_简单的动画效果
2013-07-09 01:38
363 查看
=====下面是JQuery提供的动画方法==========
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
#d1{width:200px;height:150px;background:lightgreen;}
</style>
<script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
/*
都有四个参数 slow 200、fast 400、normal 600 或者直接写毫秒时间
*/
// 显示
$("#btn1").click(function () {
$("#d1").show(1000);
});
// 隐藏
$("#btn2").click(function () {
$("#d1").hide(1000);
});
// 显示和隐藏之间去切换
$("#btn3").click(function () {
$("#d1").toggle(1000);
});
// 展开并向下滑动
$("#btn4").click(function () {
$("#d1").slideDown(1000);
});
// 收起并向上滑动
$("#btn5").click(function () {
$("#d1").slideUp(1000);
});
// 在向下滑动和向上滑动间切换
$("#btn6").click(function () {
$("#d1").slideToggle(1000);
});
// 显示并且透明度加深
$("#btn7").click(function () {
$("#d1").fadeIn(2000);
});
// 透明度减弱并隐退
$("#btn8").click(function () {
$("#d1").fadeOut(2000);
});
// 在指定的时间内将透明度减到指定的值(但是占据着一块区域)
$("#btn9").click(function () {
$("#d1").fadeTo(2000,0.0);
});
// 停止当前所有动画
$("#btnStop").click(function () {
$("#d1").stop();
});
});
</script>
</head>
<body>
<div id="d1">
</div>
<input id="btn1" type="button" value="show" /><br />
<input id="btn2" type="button" value="hide" /><br />
<input id="btn3" type="button" value="toggle" /><br />
<input id="btn4" type="button" value="slideDown" /><br />
<input id="btn5" type="button" value="slideUp" /><br />
<input id="btn6" type="button" value="slideToggle" /><br />
<input id="btn7" type="button" value="fadeIn" /><br />
<input id="btn8" type="button" value="fadeOut" /><br />
<input id="btn9" type="button" value="fadeTo" /><br />
<input id="btnStop" type="button" value="stop" /><br />
</body>
</html>
======模仿QQ列表显示实例========
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
#qqTab{width:150px;}
#qqTab li{list-style-type:none;}
#qqTab h3{background:orange;cursor:pointer;}
</style>
<script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
// 加载时列表都是隐藏的 next() 紧邻的第一个符合的节点集合
$("#qqTab h3").next("ul").hide();
// 点击分组触发的事件
$("#qqTab h3").click(function () {
// 点击分组时 显示或隐藏
$(this).next("ul").toggle("fast");
});
// 默认让好友列表显示 (窗体加载时显示)
$("#qqTab h3:first").click();
});
</script>
</head>
<body>
<div id="qqTab">
<h3>我的好友</h3>
<ul>
<li>胡主席</li>
<li>习主席</li>
<li>周总理</li>
</ul>
<h3>陌生人</h3>
<ul>
<li>张三</li>
<li>李四</li>
<li>麻子</li>
</ul>
<h3>黑名单</h3>
<ul>
<li>凤姐</li>
<li>露露</li>
<li>如花</li>
</ul>
</div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
#d1{width:200px;height:150px;background:lightgreen;}
</style>
<script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
/*
都有四个参数 slow 200、fast 400、normal 600 或者直接写毫秒时间
*/
// 显示
$("#btn1").click(function () {
$("#d1").show(1000);
});
// 隐藏
$("#btn2").click(function () {
$("#d1").hide(1000);
});
// 显示和隐藏之间去切换
$("#btn3").click(function () {
$("#d1").toggle(1000);
});
// 展开并向下滑动
$("#btn4").click(function () {
$("#d1").slideDown(1000);
});
// 收起并向上滑动
$("#btn5").click(function () {
$("#d1").slideUp(1000);
});
// 在向下滑动和向上滑动间切换
$("#btn6").click(function () {
$("#d1").slideToggle(1000);
});
// 显示并且透明度加深
$("#btn7").click(function () {
$("#d1").fadeIn(2000);
});
// 透明度减弱并隐退
$("#btn8").click(function () {
$("#d1").fadeOut(2000);
});
// 在指定的时间内将透明度减到指定的值(但是占据着一块区域)
$("#btn9").click(function () {
$("#d1").fadeTo(2000,0.0);
});
// 停止当前所有动画
$("#btnStop").click(function () {
$("#d1").stop();
});
});
</script>
</head>
<body>
<div id="d1">
</div>
<input id="btn1" type="button" value="show" /><br />
<input id="btn2" type="button" value="hide" /><br />
<input id="btn3" type="button" value="toggle" /><br />
<input id="btn4" type="button" value="slideDown" /><br />
<input id="btn5" type="button" value="slideUp" /><br />
<input id="btn6" type="button" value="slideToggle" /><br />
<input id="btn7" type="button" value="fadeIn" /><br />
<input id="btn8" type="button" value="fadeOut" /><br />
<input id="btn9" type="button" value="fadeTo" /><br />
<input id="btnStop" type="button" value="stop" /><br />
</body>
</html>
======模仿QQ列表显示实例========
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
#qqTab{width:150px;}
#qqTab li{list-style-type:none;}
#qqTab h3{background:orange;cursor:pointer;}
</style>
<script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
// 加载时列表都是隐藏的 next() 紧邻的第一个符合的节点集合
$("#qqTab h3").next("ul").hide();
// 点击分组触发的事件
$("#qqTab h3").click(function () {
// 点击分组时 显示或隐藏
$(this).next("ul").toggle("fast");
});
// 默认让好友列表显示 (窗体加载时显示)
$("#qqTab h3:first").click();
});
</script>
</head>
<body>
<div id="qqTab">
<h3>我的好友</h3>
<ul>
<li>胡主席</li>
<li>习主席</li>
<li>周总理</li>
</ul>
<h3>陌生人</h3>
<ul>
<li>张三</li>
<li>李四</li>
<li>麻子</li>
</ul>
<h3>黑名单</h3>
<ul>
<li>凤姐</li>
<li>露露</li>
<li>如花</li>
</ul>
</div>
</body>
</html>
相关文章推荐
- jQuery实现动画效果的简单实例
- 一个简单的JQuery广告动画效果
- jQuery实现简单滚动动画效果
- 【jQuery】调用animate()方法制作简单的动画效果
- jQuery之简单动画效果
- JQuery简单动画效果演示
- 用jquery写一个简单的广告动画效果
- jquery简单动画效果(上)
- Jquery实现简单的动画效果代码
- jQuery实现动画效果的简单实例
- jquery简单动画效果(下)
- jquery简单动画效果实践(一)
- JQuery(二)——简单动画效果
- jquery 最简单的动画效果
- jQuery实现简单滚动动画效果
- JQuery(二)——简单动画效果
- jquery做简单的动画效果
- JQuery实现DIV其他动画效果的简单实例
- jQuery简单动画变换效果实例分析
- jQuery学习21---简单动画效果,show,hide,slideUp,slideDown,fadeOut,fadeIn