jQuery - 综合实例 - 实现前一个和后一个效果
[示例代码]
<html>
<head>
<script src="jquery-1.2.js"></script>
<script>
$(document).ready (
function () {
$("#previous").click (
function () {
var current;
$("#items .item").each(
function (index, element) {
if ("red" === $(element).css("color")) {
current = index;
}
}
);
$("#items .item").each(
function (index, element) {
if (index === current - 1) {
$($("#items .item")[current]).css("color", "");
$(element).css("color", "red");
}
}
);
}
);
}
);
$(document).ready (
function () {
$("#next").click (
function () {
var current;
$("#items .item").each(
function (index, element) {
if ("red" === $(element).css("color")) {
current = index;
}
}
);
$("#items .item").each(
function (index, element) {
if (index === current + 1) {
$($("#items .item")[current]).css("color", "");
$(element).css("color", "red");
}
}
);
}
);
}
);
</script>
</head>
<body>
<div id="items">
<div class="item" style="color: red;">
1
</div>
<div class="item">
2
</div>
<div class="item">
3
</div>
<div class="item">
4
</div>
<div class="item">
5
</div>
<div class="item">
6
</div>
<div class="item">
7
</div>
<div class="item">
8
</div>
<div class="item">
9
</div>
<div class="item">
10
</div>
</div>
<button id="previous">
previous
</button>
<button id="next">
next
</button>
</body>
</html>
[jQuery官方网站]
http://jquery.com/[jQuery当前版本]
http://docs.jquery.com/Release:jQuery_1.2[jQuery其他下载地址]
下载列表, http://docs.jquery.com/Downloading_jQuery最新代码, http://code.jquery.com/nightlie
[jQuery相关论坛]
http://groups.google.com/group/jquery-en[jQuery关键词]
jQuery[jQuery的Ajax]
jQuery的Ajax文档, http://docs.jquery.com/Ajax/jQuery.ajaxjQuery的Ajax选项,http://docs.jquery.com/Ajax/jQuery.ajax#options
dataType选项,设置返回值类型
timeout选项,用于设置超时
与PHP集成可以使用json_encode返回结果, http://www.php.net/manual/zh/function.json-encode.php
[jQuery特效]
jQuery淡入特效,http://docs.jquery.com/Effects/fadeIn
[jQuery - Selectors选择器]
表单元素选择器, http://docs.jquery.com/DOM/Traversing/Selectors#Form_Selectors属性相等选择器,http://docs.jquery.com/Selectors/attributeEquals
checked选中, http://docs.jquery.com/Selectors/checked
选择器在选择body中出现的title标记时,会出现和预期不同的效果。
[jQuery常用函数]
attr访问自定义属性,减少javascript脚本中代码和数据的耦合
click, 绑定元素的onclick事件,http://docs.jquery.com/Events/click
filter, 用于在集合中过滤元素
click, 绑定元素的onclick事件,http://docs.jquery.com/Events/click
[jQuery - Events事件]
hover, http://docs.jquery.com/Events/hoversubmit提交, http://docs.jquery.com/Events/submit
[jQuery - Traversing遍历器]
filter过滤, http://docs.jquery.com/Traversing/filterfind查找, http://docs.jquery.com/Traversing/find
[jQuery - Tutorials教程]
Introducing $(document).ready(), http://docs.jquery.com/Tutorials:Introducing_%24%28document%29.ready%28%29[jQuery - plugins插件]
Easing动画, http://jquery.com/plugins/project/easingjCarouseLite, 走马灯效果, http://jquery.com/plugins/project/jCarouselLite
tableFilter, 表过滤器, http://jquery.com/plugins/project/tableFilter