[Ctrl+A 全选 注:如需引入外部js需刷新才能执行]
复制代码 代码如下:
<input name="" id="start" type="button" value="开始运行动画" />
<input name="" id="stop" type="button" value="终止动画" />
<div></div>
$(function(){
$("#start").click(function () {
$("div").show("slow");
$("div").animate({left:'+=200'},5000);
$("div").queue(function () {
$(this).addClass("newcolor");
$(this).dequeue();
});
$("div").animate({left:'-=200'},1500);
$("div").queue(function () {
$(this).removeClass("newcolor");
$(this).dequeue();
});
$("div").slideUp();
});
$("#stop").click(function () {
$("div").clearQueue();
$("div").stop();
});
})
jquery
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
复制代码 代码如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>delay()</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<style>
div { width: 60px; height: 60px; float: left; }
.first { background-color: #3f3; }
.second { background-color: #33f;}
</style>
</head>
<body>
<p><button>运行</button></p>
<div class="first">编程客栈;</div>
<div class="second"></div>
<script>
$("button").click(function() {
$("div.first").slideUp(300).delay(800).fadeIn(400);
$("div.second").slideUp(300).fadeIn(400);
});
</script>
</body>
</html>
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
复制代码 代码如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>detach()</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
&编程客栈lt;style>p { background:yellow; margin:6px 0; } p.off { background: black; }</style>
</head>
<body>
<button>添加/删除段落</button>
<p>这是一个用于测试的段落</p>
<script>
var p;
$("button").click(function(){
if (p) {
p.appendTo("body");
p = null;
} else {
p = $("p").detach();
}
});
</script>
</body>
</html>
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
http://www.cppcns.com
本文标题: jquery1.4 教程三 新增方法教程
本文地址: http://www.cppcns.com/wangluo/javascript/55053.html
© 著作权归作者所有
举报
发表评论
0/200