JQuery简单动画效果演示
2018-02-01 09:52
274 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JQuery动画效果演示</title>
<style type="text/css">
div{
width: 300px;
height: 300px;
background-color: yellow;
float: left;
margin: 10px;
}
</style>
<!-- 引入Jquery库 -->
<script type="text/javascript" src="jquery/jquery-1.7.2.js"></script>
<script type="text/javascript">
function func01(obj){
if(obj.value=='隐藏'){
$("#d1").hide("slow");
obj.value='显示';
}else{
$("#d1").eq(0).show("slow");
obj.value='隐藏';
}
}
function func02(obj){
if(obj.value=='隐藏'){
obj.value='显示';
}else{
obj.value='隐藏';
}
//$("#d1").toggle("slow");//切换显示隐藏
$("#d1").slideToggle("slow");//切换显示隐藏
}
function func03(obj){
$(".c1").fadeTo("slow",0.3);//变透明
$("div[id=d1]").toggle(
function(){
$(this).css("backgroundColor","red");
},
function(){
$(this).css("backgroundColor","green");
},
function(){
$(this).css("backgroundColor","blue");
}
);
}
function func04(obj){
//渐变动画效果
$(".c1").animate({height:500,width:500},
"slow",
function(){
$(this).css("backgroundColor","red");
$(this).html("<h2>效果变完了</h2>");
}
);//渐变效果
}
</script>
</head>
<body>
<input type="button" value="隐藏" onclick="func01(this);">
<input type="button" value="隐藏" onclick="func02(this);">
<input type="button" value="透明" onclick="func03(this);">
<input type="button" value="动画" onclick="func04(this);">
<hr>
<div id="d1">第一个</div>
<div id="d1">第二个</div>
<div id="d1">第三个</div>
<div class="c1">第四个</div>
<div class="c1">第五个</div>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JQuery动画效果演示</title>
<style type="text/css">
div{
width: 300px;
height: 300px;
background-color: yellow;
float: left;
margin: 10px;
}
</style>
<!-- 引入Jquery库 -->
<script type="text/javascript" src="jquery/jquery-1.7.2.js"></script>
<script type="text/javascript">
function func01(obj){
if(obj.value=='隐藏'){
$("#d1").hide("slow");
obj.value='显示';
}else{
$("#d1").eq(0).show("slow");
obj.value='隐藏';
}
}
function func02(obj){
if(obj.value=='隐藏'){
obj.value='显示';
}else{
obj.value='隐藏';
}
//$("#d1").toggle("slow");//切换显示隐藏
$("#d1").slideToggle("slow");//切换显示隐藏
}
function func03(obj){
$(".c1").fadeTo("slow",0.3);//变透明
$("div[id=d1]").toggle(
function(){
$(this).css("backgroundColor","red");
},
function(){
$(this).css("backgroundColor","green");
},
function(){
$(this).css("backgroundColor","blue");
}
);
}
function func04(obj){
//渐变动画效果
$(".c1").animate({height:500,width:500},
"slow",
function(){
$(this).css("backgroundColor","red");
$(this).html("<h2>效果变完了</h2>");
}
);//渐变效果
}
</script>
</head>
<body>
<input type="button" value="隐藏" onclick="func01(this);">
<input type="button" value="隐藏" onclick="func02(this);">
<input type="button" value="透明" onclick="func03(this);">
<input type="button" value="动画" onclick="func04(this);">
<hr>
<div id="d1">第一个</div>
<div id="d1">第二个</div>
<div id="d1">第三个</div>
<div class="c1">第四个</div>
<div class="c1">第五个</div>
</body>
</html>
相关文章推荐
- 一个简单的JQuery广告动画效果
- jQuery实现的点赞随机数字显示动画效果(附在线演示与demo源码下载)
- Javascript学习------top/left简单动画,效果与jquery的动画差不多
- jQuery实现简单滚动动画效果
- jquery简单动画效果(上)
- jQuery演示8种不同的图片遮罩层动画效果
- jQuery之简单动画效果
- JQuery(二)——简单动画效果
- jQuery实现选项卡切换效果简单演示
- JQuery—简单动画效果
- jquery简单动画效果(下)
- jQuery实现动画效果的简单实例
- jQuery动画显示和隐藏效果实例演示(附demo源码下载)
- jQuery实现Tab选项卡切换效果简单演示
- JQuery实现DIV其他动画效果的简单实例
- JQuery实现DIV其他动画效果的简单实例
- jQuery学习21---简单动画效果,show,hide,slideUp,slideDown,fadeOut,fadeIn
- jQuery实现简单滚动动画效果
- 用jquery写一个简单的广告动画效果
- jQuery实现的点赞随机数字显示动画效果(附在线演示与demo源码下载)