<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="./js/lib/jquery2.2.4/jquery-2.2.4.min.js"></script>
<style>
#box{
width:400px;
height:400px;
background: #0c79be;
}
</style>
</head>
<body>
<button id="btn1">显示--动画效果</button>
<button id="btn2">隐藏--动画效果</button>
<button id="btn3">显隐--动画效果</button>
<button id="btn4">卷帘拉开--动画效果</button>
<button id="btn5">卷帘收起--动画效果</button>
<button id="btn6">卷帘拉开/收起--动画效果</button>
<button id="btn7">透明显示--动画效果</button>
<button id="btn8">透明隐藏--动画效果</button>
<button id="btn9">透明显示/隐藏--动画效果</button>
<button id="btn10">透明指定透明度--动画效果</button>
<button id="btn11">自定义动画[常用]</button>
<div id="box"></div>
<script>
$(function(){
//给按钮绑定单击事件,测试各种动画效果:熟悉API文档
//API:application program interface 应用程序开发接口 文档
$("#btn1").click(function(){
$("#box").show(2000);//show("fast"/"slow"/1000)
});
$("#btn2").click(function(){
$("#box").hide(2000);//show("fast"/"slow"/1000)
});
$("#btn3").click(function(){
$("#box").toggle(2000);//show("fast"/"slow"/1000)
});
$("#btn4").click(function(){
$("#box").slideDown(2000);//show("fast"/"slow"/1000)
});
$("#btn5").click(function(){
$("#box").slideUp(2000);//show("fast"/"slow"/1000)
});
$("#btn6").click(function(){
$("#box").slideToggle(2000);//show("fast"/"slow"/1000)
});
$("#btn7").click(function(){
$("#box").fadeIn(2000);//show("fast"/"slow"/1000)
});
$("#btn8").click(function(){
$("#box").fadeOut(2000);//show("fast"/"slow"/1000)
});
$("#btn9").click(function(){
$("#box").fadeToggle(2000);//show("fast"/"slow"/1000)
});
$("#btn10").click(function(){
$("box").fadeTo(2000,0.5);//show("fast"/"slow"/1000)
});
$("#btn11").click(function(){
$("#box").animate({
"margin-left":"500px",
"margin-top":"50px",
"width":"1000px",
"height":"100px"
},2000).animate({
"margin-left": "0px",
"margin-top": "10px",
"width": "100px",
"height": "200px"
},1000).animate({
"margin-left": "60px",
"margin-top": "110px",
"width": "10px",
"height": "20px"
},1000).animate({
"margin-left": "0px",
"margin-top": "0px",
"width": "400px",
"height": "200px"
},1000);
});
});
</script>
</body>
</html>
JQuery 按钮绑定事件
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 第一步:获取页面的ul,button 第二步:动态创建li元素 第三步:把li元素追加到ul中 第四步: ``` ...
- jquery 如何绑定事件 事件处理中最头疼的就是浏览器兼容问题,jQuery封装了很好的API,可以方便的进行事...
- 在cocos creator中对按钮的事件绑定分为两种,一种是通过属性面板绑定。一种是用过代码绑定。今天我在这里主...
- (1)现象:引用jQuery Mobile,为页面中的一个button绑定事件,使用submit按钮提交表单。结果...