个人认为学习jQuery核心要会js以及会查中文文档
一个JS函数库: write less, do more
封装简化DOM操作(CRUD) / Ajax
<html>
<head>
<meta charset="UTF-8">
<title>01_初识jQuerytitle>
<script type="text/javascript">
window.onload = function() {
var btn1 = document.getElementById('btn1')
btn1.onclick = function() {
var username = document.getElementById('username').value
alert(username)
}
}
script>
<script type="text/javascript" src="js/jquery-1.12.3.js">script>
<script type="text/javascript">
//绑定文档加载完成的监听
$(function (){
$("#btn2").click(function (){
var username = $("#username").val();
alert(username);
})
})
/*
1. 使用jQuery核心函数: $或者jQuery
2. 使用jQuery核心对象: 执行$()返回的对象
*/
//新的注释
script>
head>
<body>
用户名: <input type="text" id="username">
<button id="btn1">确定(原生版)button>
<button id="btn2">确定(jQuery版)button>
body>
html>
<html>
<head>
<meta charset="UTF-8">
<title>jQuery的两把利器title>
head>
<body>
<button>测试button>
<script type="text/javascript" src="js/jquery-1.12.3.js">script>
<script type="text/javascript">
//1. jQuery函数: 直接可用
console.log($, typeof $);
console.log(jQuery === $); // true
//2. jQuery对象: 执行jQuery函数得到它
console.log($() instanceof Object) ;// true
/*
(function (window) {
var jQuery = function () {
return new xxx();
}
window.$ = window.jQuery = jQuery;
})(window)
*/
script>
body>
html>
<html>
<head>
<meta charset="UTF-8">
<title>03_jQuery核心函数title>
head>
<body>
<div>
<button id="btn">测试button>
<br />
<input type="text" name="msg1" /><br />
<input type="text" name="msg2" /><br />
div>
<script src="js/jquery-1.10.1.js" type="text/javascript">script>
<script type="text/javascript">
/*
需求1. 点击按钮: 显示按钮的文本, 显示一个新的输入框
需求2. 遍历输出数组中所有元素值
需求3. 去掉" my atguigu "两端的空格
*/
/*需求1. 点击按钮: 显示按钮的文本, 显示一个新的输入框*/
//1.1). 参数为函数 : 当DOM加载完成后,执行此回调函数
$(function() { // 绑定文档加载完成的监听
// 1.2). 参数为选择器字符串: 查找所有匹配的标签, 并将它们封装成jQuery对象
$('#btn').click(function() { // 绑定点击事件监听
// this是什么? 发生事件的dom元素(
// alert(this.innerHTML)
// 1.3). 参数为DOM对象: 将dom对象封装成jQuery对象
alert($(this).html())
// 1.4). 参数为html标签字符串 (用得少): 创建标签对象并封装成jQuery对象
$('
').appendTo('div')
})
})
/*需求2. 遍历输出数组中所有元素值*/
var arr = [2, 4, 7]
// 1). $.each() : 隐式遍历数组
$.each(arr, function(index, item) {
console.log(index, item)
})
// 2). $.trim() : 去除两端的空格
var str = ' my atguigu '
// console.log('---'+str.trim()+'---')
console.log('---' + $.trim(str) + '---')
script>
body>
html>
<html>
<head>
<meta charset="UTF-8">
<title>04_jQuery对象title>
head>
<body>
<button>测试一button>
<button>测试二button>
<button id="btn3">测试三button>
<button>测试四button>
<script src="js/jquery-1.10.1.js" type="text/javascript">script>
<script type="text/javascript">
/*
需求:
需求1. 统计一共有多少个按钮
需求2. 取出第2个button的文本
需求3. 输出所有button标签的文本
需求4. 输出'测试三'按钮是所有按钮中的第几个
*/
//需求1. 统计一共有多少个按钮
var $buttons = $('button'); //返回的是jQuery对象
/*size()/length: 包含的DOM元素个数*/
console.log($buttons.size(), $buttons.length);
//需求2. 取出第2个button的文本
/*[index]/get(index): 返回的是对应位置的DOM元素*/
console.log($buttons[1].innerHTML, $buttons.get(1).innerHTML);
//需求3. 输出所有button标签的文本
/*each(): 遍历包含的所有DOM元素*/
/*$buttons.each(function (index, domEle) {
console.log(index, domEle.innerHTML, this)
})*/
$buttons.each(function() {
console.log(this.innerHTML);
})
//需求4. 输出'测试三'按钮是所有按钮中的第几个
/*index(): 得到在所在兄弟元素中的下标*/
console.log($('#btn3').index()); //2
/*
1. 伪数组
* Object对象
* length属性
* 数值下标属性
* 没有数组特别的方法: forEach(), push(), pop(), splice()
*/
console.log($buttons instanceof Array); // false
// 自定义一个伪数组
var weiArr = {};
weiArr.length = 0;
weiArr[0] = 'atguigu';
weiArr.length = 1;
weiArr[1] = 123;
weiArr.length = 2;
for (var i = 0; i < weiArr.length; i++) {
var obj = weiArr[i];
console.log(i, obj);
}
console.log(weiArr.forEach, $buttons.forEach); //undefined, undefined
script>
body>
html>
<html>
<head>
<meta charset="UTF-8">
<title>05_基本选择器title>
head>
<body>
<div id="div1" class="box">div1(class="box")div>
<div id="div2" class="box">div2(class="box")div>
<div id="div3">div3div>
<span class="box">span(class="box")span>
<br>
<ul>
<li>AAAAAli>
<li title="hello">BBBBB(title="hello")li>
<li class="box">CCCCC(class="box")li>
<li title="hello">DDDDDD(title="hello")li>
ul>
<script src="js/jquery-1.10.1.js" type="text/javascript">script>
<script type="text/javascript">
/*
需求:
1. 选择id为div1的元素
2. 选择所有的div元素
3. 选择所有class属性为box的元素
4. 选择所有的div和span元素
5. 选择所有class属性为box的div元素
*/
//1. 选择id为div1的元素
// $('#div1').css('background', 'red');
//2. 选择所有的div元素
// $('div').css('background', 'red');
/* $("div").css({background:"red"}); */
//3. 选择所有class属性为box的元素
//$('.box').css('background', 'red');
//4. 选择所有的div和span元素
// $('div,span').css('background', 'red');
//5. 选择所有class属性为box的div元素
//$('div.box').css('background', 'red');
//$('*').css('background', 'red');
script>
body>
html>
<html>
<head>
<meta charset="UTF-8">
<title>06_层次选择器title>
head>
<body>
<ul>
<li>AAAAAli>
<li class="box">CCCCCli>
<li title="hello"><span>BBBBBspan>li>
<li title="hello"><span class="box">DDDDspan>li>
<span>EEEEEspan>
ul>
<script src="js/jquery-1.10.1.js" type="text/javascript">script>
<script type="text/javascript">
/*
需求:
1. 选中ul下所有的的span
2. 选中ul下所有的子元素span
3. 选中class为box的下一个li
4. 选中ul下的class为box的元素后面的所有兄弟元素
*/
//1. 选中ul下所有的的span
// $('ul span').css('background', 'yellow')
//2. 选中ul下所有的子元素span
// $('ul>span').css('background', 'yellow')
//3. 选中class为box的下一个li
// $('.box+li').css('background', 'yellow')
//4. 选中ul下的class为box的元素后面的所有兄弟元素
$('ul .box~*').css('background', 'yellow')
script>
body>
html>
<html>
<head>
<meta charset="UTF-8">
<title>07_过滤选择器title>
head>
<body>
<div id="div1" class="box">class为box的div1div>
<div id="div2" class="box">class为box的div2div>
<div id="div3">div3div>
<span class="box">class为box的spanspan>
<br />
<ul>
<li>AAAAAli>
<li title="hello">BBBBBli>
<li class="box">CCCCCli>
<li title="hello">DDDDDDli>
<li title="two">BBBBBli>
<li style="display:none">我本来是隐藏的li>
ul>
<script src="js/jquery-1.12.3.js" type="text/javascript">script>
<script type="text/javascript">
/*
需求:
1. 选择第一个div
2. 选择最后一个class为box的元素
3. 选择所有class属性不为box的div
4. 选择第二个和第三个li元素
5. 选择内容为BBBBB的li
6. 选择隐藏的li
7. 选择有title属性的li元素
8. 选择所有属性title为hello的li元素
*/
//1. 选择第一个div
// $('div:first').css('background', 'red')
//2. 选择最后一个class为box的元素
//$('.box:last').css('background', 'red')
//3. 选择所有class属性不为box的div
// $('div:not(.box)').css('background', 'red') //没有class属性也可以
//4. 选择第二个和第三个li元素
// $('li:gt(0):lt(2)').css('background', 'red') // 多个过滤选择器不是同时执行, 而是依次
//$('li:lt(3):gt(0)').css('background', 'red')
//5. 选择内容为BBBBB的li
// $('li:contains("BBBBB")').css('background', 'red')
//6. 选择隐藏的li
// console.log($('li:hidden').length, $('li:hidden')[0])
//7. 选择有title属性的li元素
// $('li[title]').css('background', 'red')
//8. 选择所有属性title为hello的li元素
$('li[title="hello"]').css('background', 'red')
script>
body>
html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>01__表格隔行变色title>
<style>
div, span, p {
width: 140px;
height: 140px;
margin: 5px;
background: #aaa;
border: #000 1px solid;
float: left;
font-size: 17px;
font-family: Verdana;
}
div.mini {
width: 55px;
height: 55px;
background-color: #aaa;
font-size: 12px;
}
div.hide {
display: none;
}
#data {
width: 600px;
}
#data, td, th {
border-collapse: collapse;
border: 1px solid #aaaaaa;
}
th, td {
height: 28px;
}
#data thead {
background-color: #333399;
color: #ffffff;
}
.odd {
background-color: #ccccff;
}
style>
head>
<body>
<table id="data">
<thead>
<tr>
<th>姓名th>
<th>工资th>
<th>入职时间th>
<th>操作th>
tr>
thead>
<tbody>
<tr>
<td>Tomtd>
<td>$3500td>
<td>2010-10-25td>
<td><a href="javascript:void(0)">删除a>td>
tr>
<tr>
<td>Marytd>
<td>$3400td>
<td>2010-12-1td>
<td><a href="javascript:void(0)">删除a>td>
tr>
<tr>
<td>Kingtd>
<td>$5900td>
<td>2009-08-17td>
<td><a href="javascript:void(0)">删除a>td>
tr>
<tr>
<td>Scotttd>
<td>$3800td>
<td>2012-11-17td>
<td><a href="javascript:void(0)">删除a>td>
tr>
<tr>
<td>Smithtd>
<td>$3100td>
<td>2014-01-27td>
<td><a href="javascript:void(0)">删除a>td>
tr>
<tr>
<td>Allentd>
<td>$3700td>
<td>2011-12-05td>
<td><a href="javascript:void(0)">删除a>td>
tr>
tbody>
table>
<script type="text/javascript" src="jquery-1.10.1.js">script>
<script type="text/javascript">
$('#data>tbody>tr:odd').css('background', '#ccccff')
// $('#data>tbody>tr:odd').addClass('odd')
//$('#data>tbody>tr:odd').attr('class', 'odd')
script>
body>
html>
<html>
<head>
<meta charset="UTF-8">
<title>08_表单选择器title>
head>
<body>
<form>
用户名: <input type="text" /><br>
密 码: <input type="password" /><br>
爱 好:
<input type="checkbox" checked="checked" />篮球
<input type="checkbox" />足球
<input type="checkbox" checked="checked" />羽毛球 <br>
性 别:
<input type="radio" name="sex" value='male' />男
<input type="radio" name="sex" value='female' />女<br>
邮 箱: <input type="text" name="email" disabled="disabled" /><br>
所在地:
<select>
<option value="1">北京option>
<option value="2" selected="selected">天津option>
<option value="3">河北option>
select><br>
<input type="submit" value="提交" />
form>
<script src="js/jquery-1.10.1.js" type="text/javascript">script>
<script type="text/javascript">
/*
需求:
1. 选择不可用的文本输入框
2. 显示选择爱好 的个数
3. 显示选择的城市名称
*/
//1. 选择不可用的文本输入框
// $(':text:disabled').css('background', 'red')
//2. 显示选择爱好 的个数
console.log($(':checkbox:checked').length)
//3. 显示选择的城市名称
$(':submit').click(function() {
var city = $('select>option:selected').html(); // 选择的option的标签体文本
city = $('select').val();// 选择的option的value属性值
alert(city);
})
script>
body>
html>
<html>
<head>
<meta charset="UTF-8">
<title>09_$工具方法title>
head>
<body>
<script src="js/jquery-1.10.1.js" type="text/javascript">script>
<script type="text/javascript">
//1. $.each(): 遍历数组或对象中的数据
var obj = {
name: 'Tom',
setName: function(name) {
this.name = name
}
}
$.each(obj, function(key, value) {
console.log(key, value)
})
//2. $.trim(): 去除字符串两边的空格
//3. $.type(obj): 得到数据的类型
console.log($.type($)) // 'function'
//4. $.isArray(obj): 判断是否是数组
console.log($.isArray($('body')), $.isArray([])) // false true
//5. $.isFunction(obj): 判断是否是函数
console.log($.isFunction($)) // true
//6. $.parseJSON(json) : 解析json字符串转换为js对象/数组
var json = '{"name":"Tom", "age":12}' // json对象: {}
// json对象===>JS对象
console.log($.parseJSON(json))
json = '[{"name":"Tom", "age":12}, {"name":"JACK", "age":13}]' // json数组: []
// json数组===>JS数组
console.log($.parseJSON(json))
/*
JSON.parse(jsonString) json字符串--->js对象/数组
JSON.stringify(jsObj/jsArr) js对象/数组--->json字符串
*/
script>
body>
html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>02_多Tab点击切换title>
<style>
* {
margin: 0;
padding: 0;
}
#tab li {
float: left;
list-style: none;
width: 80px;
height: 40px;
line-height: 40px;
cursor: pointer;
text-align: center;
}
#container {
position: relative;
}
#content1, #content2, #content3 {
width: 300px;
height: 100px;
padding: 30px;
position: absolute;
top: 40px;
left: 0;
}
#tab1, #content1 {
background-color: #ffcc00;
}
#tab2, #content2 {
background-color: #ff00cc;
}
#tab3, #content3 {
background-color: #00ccff;
}
style>
head>
<body>
<h2>多Tab点击切换h2>
<ul id="tab">
<li id="tab1" value="1">10元套餐li>
<li id="tab2" value="2">30元套餐li>
<li id="tab3" value="3">50元包月li>
ul>
<div id="container">
<div id="content1">
10元套餐详情:<br /> 每月套餐内拨打100分钟,超出部分2毛/分钟
div>
<div id="content2" style="display: none">
30元套餐详情:<br /> 每月套餐内拨打300分钟,超出部分1.5毛/分钟
div>
<div id="content3" style="display: none">
50元包月详情:<br /> 每月无限量随心打
div>
div>
<script type="text/javascript" src="jquery-1.10.1.js">script>
<script type="text/javascript">
var $contents = $('#container>div')
// 给3个li加监听
/*$('#tab>li').click(function () { // 隐式遍历
//alert('----')
// 隐隐藏所有内容div
$contents.css('display', 'none')
// 显示对应的内容div
// 得到当前点击的li在兄弟中下标
var index = $(this).index()
// 找到对应的内容div, 并显示
$contents[index].style.display = 'block'
// $($contents[index]).css('display', 'block')
})*/
var currIndex = 0 //当前显示的内容div的下标
$('#tab>li').click(function() { // 隐式遍历
//alert('----')
// 隐藏当前已经显示的内容div
$contents[currIndex].style.display = 'none'
// 显示对应的内容div
// 得到当前点击的li在兄弟中下标
var index = $(this).index()
// 找到对应的内容div, 并显示
$contents[index].style.display = 'block'
// 更新下标
currIndex = index
})
script>
body>
html>
<html>
<head>
<meta charset="UTF-8">
<title>10_属性title>
head>
<body>
<div id="div1" class="box" title="one">class为box的div1div>
<div id="div2" class="box" title="two">class为box的div2div>
<div id="div3">div3div>
<span class="box">class为box的spanspan>
<br />
<ul>
<li>AAAAAli>
<li title="hello" class="box2">BBBBBli>
<li class="box">CCCCCli>
<li title="hello">DDDDDDli>
<li title="two"><span>BBBBBspan>li>
ul>
<input type="text" name="username" value="guiguClass" />
<br>
<input type="checkbox">
<input type="checkbox">
<br>
<button>选中button>
<button>不选中button>
<script src="js/jquery-1.10.1.js" type="text/javascript">script>
<script type="text/javascript">
/*
需求:
1. 读取第一个div的title属性
2. 给所有的div设置name属性(value为atguigu)
3. 移除所有div的title属性
4. 给所有的div设置class='guiguClass'
5. 给所有的div添加class='abc'
6. 移除所有div的guiguClass的class
7. 得到最后一个li的标签体文本
8. 设置第一个li的标签体为"mmmmmmmmm
"
9. 得到输入框中的value值
10. 将输入框的值设置为atguigu
11. 点击'全选'按钮实现全选
12. 点击'全不选'按钮实现全不选
*/
//1. 读取第一个div的title属性
// console.log($('div:first').attr('title')) // one
//2. 给所有的div设置name属性(value为atguigu)
// $('div').attr('name', 'atguigu')
//3. 移除所有div的title属性
// $('div').removeAttr('title')
//4. 给所有的div设置class='guiguClass'
//$('div').attr('class', 'guiguClass')
//5. 给所有的div添加class='abc'
//$('div').addClass('abc')
//6. 移除所有div的guiguClass的class
//$('div').removeClass('guiguClass')
//7. 得到最后一个li的标签体文本
//console.log($('li:last').html())
//8. 设置第一个li的标签体为"mmmmmmmmm
"
//$('li:first').html('mmmmmmmmm
')
//9. 得到输入框中的value值
//console.log($(':text').val()) // 读取
//10. 将输入框的值设置为atguigu
//$(':text').val('atguigu') // 设置 读写合一
//11. 点击'全选'按钮实现全选
// attr(): 操作属性值为非布尔值的属性
// prop(): 专门操作属性值为布尔值的属性
var $checkboxs = $(':checkbox')
$('button:first').click(function() {
$checkboxs.prop('checked', true)
})
//12. 点击'全不选'按钮实现全不选
$('button:last').click(function() {
$checkboxs.prop('checked', false)
})
script>
body>
html>
<html>
<head>
<meta charset="UTF-8">
<title>11_csstitle>
head>
<body>
<p style="color: blue;">月亮的后裔p>
<p style="color: green;">太阳的后裔p>
<script src="js/jquery-1.10.1.js" type="text/javascript">script>
<script type="text/javascript">
/*
1. 得到第一个p标签的颜色
2. 设置所有p标签的文本颜色为red
3. 设置第2个p的字体颜色(#ff0011),背景(blue),宽(300px), 高(30px)
*/
//1. 得到第一个p标签的颜色
//console.log($('p:first').css('color'))
//2. 设置所有p标签的文本颜色为red
//$('p').css('color', 'red')
//3. 设置第2个p的字体颜色(#ff0011),背景(blue),宽(300px), 高(30px)
$('p:eq(1)').css({
color: '#ff0011',
background: 'blue',
width: 300,
height: 30
})
script>
body>
html>
<html>
<head>
<meta charset="UTF-8">
<title>12_offset和positiontitle>
head>
<style type="text/css">
* {
margin: 0px;
}
.div1 {
position: absolute;
width: 200px;
height: 200px;
top: 20px;
left: 10px;
background: blue;
}
.div2 {
position: absolute;
width: 100px;
height: 100px;
top: 50px;
background: red;
}
.div3 {
position: absolute;
top: 250px;
}
style>
<body style="height: 2000px;">
<div class="div1">
<div class="div2">测试offsetdiv>
div>
<div class='div3'>
<button id="btn1">读取offset和positionbutton>
<button id="btn2">设置offsetbutton>
div>
<script src="js/jquery-1.10.1.js" type="text/javascript">script>
<script type="text/javascript">
/*
需求:
1. 点击 btn1
打印 div1 相对于页面左上角的位置
打印 div2 相对于页面左上角的位置
打印 div1 相对于父元素左上角的位置
打印 div2 相对于父元素左上角的位置
2. 点击 btn2
设置 div2 相对于页面的左上角的位置
*/
$('#btn1').click(function() {
// 打印 div1 相对于页面左上角的位置
var offset = $('.div1').offset()
console.log(offset.left, offset.top) // 10 20
// 打印 div2 相对于页面左上角的位置
offset = $('.div2').offset()
console.log(offset.left, offset.top) // 10 70
// 打印 div1 相对于父元素左上角的位置
var position = $('.div1').position()
console.log(position.left, position.top) // 10 20
// 打印 div2 相对于父元素左上角的位置
position = $('.div2').position()
console.log(position.left, position.top) // 0 50
})
$('#btn2').click(function() {
$('.div2').offset({
left: 50,
top: 100
})
})
script>
body>
html>
<html>
<head>
<meta charset="UTF-8">
<title>13_元素滚动title>
head>
<body style="height: 2000px;">
<div style="border:1px solid black;width:100px;height:150px;overflow:auto">
This is some text. This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text. This is some text.
his is some text.
div>
<br>
<br>
<br>
<button id="btn1">得到scrollTopbutton>
<button id="btn2">设置scrollTopbutton>
<script src="js/jquery-1.10.1.js">script>
<script>
/*
需求:
1. 得到div或页面滚动条的坐标
2. 让div或页面的滚动条滚动到指定位置
*/
//1. 得到div或页面滚动条的坐标
$('#btn1').click(function() {
console.log($('div').scrollTop())
// console.log($('html').scrollTop()+$('body').scrollTop())
console.log($(document.documentElement).scrollTop() + $(document.body).scrollTop()) // 兼容IE/Chrome
})
//2. 让div或页面的滚动条滚动到指定位置
$('#btn2').click(function() {
$('div').scrollTop(200)
$('html,body').scrollTop(300)
})
script>
body>
html>
<html>
<head>
<meta charset="UTF-8">
<title>03_回到顶部title>
<style>
#to_top {
width: 30px;
height: 40px;
font: 14px/20px arial;
text-align: center;
background: #06c;
position: fixed;
cursor: pointer;
color: #fff;
left: 1050px;
top: 500px;
}
style>
head>
<body style="height: 2000px;">
<div id="to_top">返回顶部div>
<script type="text/javascript" src="../js/jquery-1.10.1.js">script>
<script type="text/javascript">
$('#to_top').click(function() {
// 瞬间滚到顶部
//$('html,body').scrollTop(0)
// 平滑滚到顶部
// 总距离
var $page = $('html,body')
var distance = $('html').scrollTop() + $('body').scrollTop()
// 总时间
var time = 500
// 间隔时间
var intervalTime = 50
var itemDistance = distance / (time / intervalTime)
// 使用循环定时器不断滚动
clearInterval(intervalId);
var intervalId = setInterval(function() {
distance -= itemDistance
// 到达顶部, 停止定时器
if (distance <= 0) {
distance = 0 //修正
clearInterval(intervalId)
}
$page.scrollTop(distance)
}, intervalTime)
})
script>
body>
html>
<html>
<head>
<meta charset="UTF-8">
<title>14_元素的尺寸title>
head>
<style>
div {
width: 100px;
height: 150px;
background: red;
padding: 10px;
border: 10px #fbd850 solid;
margin: 10px;
}
style>
head>
<body>
<div>divdiv>
<script src="js/jquery-1.10.1.js" type="text/javascript">script>
<script>
var $div = $('div')
// 1. 内容尺寸
console.log($div.width(), $div.height()) // 100 150
// 2. 内部尺寸
console.log($div.innerWidth(), $div.innerHeight()) //120 170
// 3. 外部尺寸
console.log($div.outerWidth(), $div.outerHeight()) //140 190
console.log($div.outerWidth(true), $div.outerHeight(true)) //160 210
script>
body>
html>
<html>
<head>
<meta charset="UTF-8">
<title>15_筛选_过滤title>
head>
<body>
<ul>
<li>AAAAAli>
<li title="hello" class="box2">BBBBBli>
<li class="box">CCCCCli>
<li title="hello">DDDDDDli>
<li title="two"><span>BBBBBspan>li>
ul>
<li>eeeeeli>
<li>EEEEEli>
<br>
<script src="js/jquery-1.10.1.js" type="text/javascript">script>
<script type="text/javascript">
/*
需求:
1. ul下li标签第一个
2. ul下li标签的最后一个
3. ul下li标签的第二个
4. ul下li标签中title属性为hello的
5. ul下li标签中title属性不为hello的
6. ul下li标签中有span子标签的
*/
var $lis = $('ul>li')
//1. ul下li标签第一个
// $lis.first().css('background', 'red')
// $lis[0].style.background = 'red'
//2. ul下li标签的最后一个
// $lis.last().css('background', 'red')
//3. ul下li标签的第二个
// $lis.eq(1).css('background', 'red')
//4. ul下li标签中title属性为hello的
// $lis.filter('[title=hello]').css('background', 'red')
//5. ul下li标签中title属性不为hello的
// $lis.not('[title=hello]').css('background', 'red')
// $lis.filter('[title!=hello]').filter('[title]').css('background', 'red')
//6. ul下li标签中有span子标签的
$lis.has('span').css('background', 'red')
script>
body>
html>
<html>
<head>
<meta charset="UTF-8">
<title>16_筛选_查找孩子-父母-兄弟标签title>
head>
<body>
<div id="div1" class="box" title="one">class为box的div1div>
<div id="div2" class="box">class为box的div2div>
<div id="div3">div3div>
<span class="box">class为box的spanspan>
<br />
<div>
<ul>
<span>span文本1span>
<li>AAAAAli>
<li title="hello" class="box2">BBBBBli>
<li class="box" id='cc'>CCCCCli>
<li title="hello">DDDDDDli>
<li title="two"><span>span文本2span>li>
<span>span文本3span>
ul>
<span>span文本444span><br>
<li>eeeeeli>
<li>EEEEEli>
<br>
div>
<script src="js/jquery-1.10.1.js" type="text/javascript">script>
<script type="text/javascript">
/*
需求:
1. ul标签的第2个span子标签
2. ul标签的第2个span后代标签
3. ul标签的父标签
4. id为cc的li标签的前面的所有li标签
5. id为cc的li标签的所有兄弟li标签
*/
var $ul = $('ul')
//1. ul标签的第2个span子标签
//$ul.children('span:eq(1)').css('background', 'red')
//2. ul标签的第2个span后代标签
// $ul.find('span:eq(1)').css('background', 'red')
//3. ul标签的父标签
// $ul.parent().css('background', 'red')
//4. id为cc的li标签的前面的所有li标签
var $li = $('#cc')
// $li.prevAll('li').css('background', 'red')
//5. id为cc的li标签的所有兄弟li标签
$li.siblings('li').css('background', 'red')
script>
body>
html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>全选练习title>
head>
<body>
<form>
你爱好的运动是?<input type="checkbox" id="checkedAllBox" />全选/全不选
<br />
<input type="checkbox" name="items" value="足球" />足球
<input type="checkbox" name="items" value="篮球" />篮球
<input type="checkbox" name="items" value="羽毛球" />羽毛球
<input type="checkbox" name="items" value="乒乓球" />乒乓球
<br />
<input type="button" id="checkedAllBtn" value="全 选" />
<input type="button" id="checkedNoBtn" value="全不选" />
<input type="button" id="checkedRevBtn" value="反 选" />
<input type="button" id="sendBtn" value="提 交" />
form>
<script type="text/javascript" src="../js/jquery-1.10.1.js">script>
<script type="text/javascript">
/*
功能说明:
1. 点击'全选': 选中所有爱好
2. 点击'全不选': 所有爱好都不勾选
3. 点击'反选': 改变所有爱好的勾选状态
4. 点击'提交': 提示所有勾选的爱好
5. 点击'全选/全不选': 选中所有爱好, 或者全不选中
6. 点击某个爱好时, 必要时更新'全选/全不选'的选中状态
*/
var $checkedAllBox = $('#checkedAllBox')
var $items = $(':checkbox[name=items]')
// 1. 点击'全选': 选中所有爱好
$('#checkedAllBtn').click(function() {
$items.prop('checked', true)
$checkedAllBox.prop('checked', true)
})
// 2. 点击'全不选': 所有爱好都不勾选
$('#checkedNoBtn').click(function() {
$items.prop('checked', false)
$checkedAllBox.prop('checked', false)
})
// 3. 点击'反选': 改变所有爱好的勾选状态
$('#checkedRevBtn').click(function() {
$items.each(function() {
this.checked = !this.checked
})
$checkedAllBox.prop('checked', $items.filter(':not(:checked)').length === 0)
})
//4. 点击'提交': 提示所有勾选的爱好
$('#sendBtn').click(function() {
$items.filter(':checked').each(function() {
alert(this.value)
})
})
// 5. 点击'全选/全不选': 选中所有爱好, 或者全不选中
$checkedAllBox.click(function() {
$items.prop('checked', this.checked)
})
// 6. 点击某个爱好时, 必要时更新'全选/全不选'的选中状态
$items.click(function() {
$checkedAllBox.prop('checked', $items.filter(':not(:checked)').length === 0)
})
script>
body>
html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>全选练习title>
head>
<body>
<form method="post" action="">
你爱好的运动是?<input type="checkbox" id="checkedAllBox" />全选/全不选
<br />
<input type="checkbox" name="items" value="足球" />足球
<input type="checkbox" name="items" value="篮球" />篮球
<input type="checkbox" name="items" value="羽毛球" />羽毛球
<input type="checkbox" name="items" value="乒乓球" />乒乓球
<br />
<input type="button" id="checkedAllBtn" value="全 选" />
<input type="button" id="checkedNoBtn" value="全不选" />
<input type="button" id="checkedRevBtn" value="反 选" />
<input type="button" id="sendBtn" value="提 交" />
form>
<script type="text/javascript">
/*
功能说明:
1. 点击'全选': 选中所有爱好
2. 点击'全不选': 所有爱好都不勾选
3. 点击'反选': 改变所有爱好的勾选状态
4. 点击'提交': 提示所有勾选的爱好
5. 点击'全选/全不选': 选中所有爱好, 或者全不选中
6. 点击某个爱好时, 必要时更新'全选/全不选'的选中状态
技术点:
1.DOM查询
2.事件回调函数绑定
3.checkbox操作
4.事件回调函数中的this
5.逻辑思维能力
*/
window.onload = function() {
var items = document.getElementsByName("items");
//1.#checkedAllBtn
var checkedAllBtn = document.getElementById("checkedAllBtn");
checkedAllBtn.onclick = function() {
setItemsChecked(true);
checkedAllBox.checked = true;
};
//2.#checkedNoBtn
var checkedNoBtn = document.getElementById("checkedNoBtn");
checkedNoBtn.onclick = function() {
setItemsChecked(false);
checkedAllBox.checked = false;
};
//3.#checkedRevBtn
var checkedRevBtn = document.getElementById("checkedRevBtn");
checkedRevBtn.onclick = function() {
setItemsChecked();
//点满时将checkedAllBox.checked设置为true
//统计当前items中被选中的个数
checkedAllBox.checked = isAllChecked();
};
//4.#checkedAllBox
var checkedAllBox = document.getElementById("checkedAllBox");
checkedAllBox.onclick = function() {
setItemsChecked(this.checked);
};
//5.#sendBtn
var sendBtn = document.getElementById("sendBtn");
sendBtn.onclick = function() {
for (var i = 0; i < items.length; i++) {
if (items[i].checked) {
alert(items[i].value);
}
}
};
//6.items
for (var i = 0; i < items.length; i++) {
items[i].onclick = function() {
//点满时将checkedAllBox.checked设置为true
//统计当前items中被选中的个数
checkedAllBox.checked = isAllChecked();
}
}
function isAllChecked() {
for (var j = 0; j < items.length; j++) {
if (!items[j].checked)
return false;
}
return true;
}
function setItemsChecked(checked) {
for (var i = 0; i < items.length; i++) {
items[i].checked = (checked == undefined) ? (!items[i].checked) : checked;
}
}
}
script>
body>
html>
<html>
<head>
<meta charset="UTF-8">
<title>17_文档_增删改title>
head>
<style type="text/css">
* {
margin: 0px;
}
.div1 {
position: absolute;
width: 200px;
height: 200px;
top: 20px;
left: 10px;
background: blue;
}
.div2 {
position: absolute;
width: 100px;
height: 100px;
/*top: 50px;*/
background: red;
}
.div3 {
position: absolute;
top: 250px;
}
style>
<body>
<ul id="ul1">
<li>AAAAAli>
<li title="hello">BBBBBli>
<li class="box">CCCCCli>
<li title="hello">DDDDDDli>
<li title="two">EEEEEli>
<li>FFFFFli>
ul>
<br>
<br>
<ul id="ul2">
<li>aaali>
<li title="hello">bbbli>
<li class="box">cccli>
<li title="hello">dddli>
<li title="two">eeeli>
ul>
<script src="js/jquery-1.10.1.js" type="text/javascript">script>
<script type="text/javascript">
/*
需求:
1. 向id为ul1的ul下添加一个span(最后)
2. 向id为ul1的ul下添加一个span(最前)
3. 在id为ul1的ul下的li(title为hello)的前面添加span
4. 在id为ul1的ul下的li(title为hello)的后面添加span
5. 将在id为ul2的ul下的li(title为hello)全部替换为p
6. 移除id为ul2的ul下的所有li
*/
//1. 向id为ul1的ul下添加一个span(最后)
var $ul1 = $('#ul1')
// $ul1.append('append()添加的span')
$('appendTo()添加的span').appendTo($ul1)
//2. 向id为ul1的ul下添加一个span(最前)
// $ul1.prepend('prepend()添加的span')
$('prependTo()添加的span').prependTo($ul1)
//3. 在id为ul1的ul下的li(title为hello)的前面添加span
$ul1.children('li[title=hello]').before('before()添加的span')
//4. 在id为ul1的ul下的li(title为hello)的后面添加span
$ul1.children('li[title=hello]').after('after()添加的span')
//5. 将在id为ul2的ul下的li(title为hello)全部替换为p
$('#ul2>li[title=hello]').replaceWith('replaceAll()替换的p
')
//6. 移除id为ul2的ul下的所有li
// $('#ul2').empty() // 也会删除
$('#ul2>li').remove()
script>
body>
html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加删除记录练习title>
<link rel="stylesheet" type="text/css" href="../css/css.css" />
head>
<body>
<table id="employeeTable">
<tr>
<th>Nameth>
<th>Emailth>
<th>Salaryth>
<th> th>
tr>
<tr>
<td>Tomtd>
<td>[email protected]td>
<td>5000td>
<td><a href="deleteEmp?id=001">Deletea>td>
tr>
<tr>
<td>Jerrytd>
<td>[email protected]td>
<td>8000td>
<td><a href="deleteEmp?id=002">Deletea>td>
tr>
<tr>
<td>Bobtd>
<td>[email protected]td>
<td>10000td>
<td><a href="deleteEmp?id=003">Deletea>td>
tr>
table>
<div id="formDiv">
<h4>添加新员工h4>
<table>
<tr>
<td class="word">name:td>
<td class="inp">
<input type="text" name="empName" id="empName" />
td>
tr>
<tr>
<td class="word">email:td>
<td class="inp">
<input type="text" name="email" id="email" />
td>
tr>
<tr>
<td class="word">salary:td>
<td class="inp">
<input type="text" name="salary" id="salary" />
td>
tr>
<tr>
<td colspan="2" align="center">
<button id="addEmpButton" value="abc">
Submit
button>
td>
tr>
table>
div>
<script type="text/javascript" src="jquery-1.10.1.js">script>
<script type="text/javascript">
/*
1. 添加
2. 删除
*/
$('#addEmpButton').click(function() {
//1. 收集输入的数据
var $empName = $('#empName')
var $email = $('#email')
var $salary = $('#salary')
var empName = $empName.val()
var email = $email.val()
var salary = $salary.val()
//2. 生成对应的标签结构, 并插入#employeeTable的tbody中
/*
Bob
[email protected]
10000
Delete
*/
$(' ')
.append('' + empName + ' ') // 拼串
.append('' + email + ' ')
.append('' + salary + ' ')
.append(' + Date.now() + '>Delete ')
.appendTo('#employeeTable>tbody')
.find('a')
.click(clickDelete)
//3. 清除输入
$empName.val('')
$email.val('')
$salary.val('')
})
// 给所有删除链接绑定点击监听
$('#employeeTable a').click(clickDelete)
/*
点击删除的回调函数
*/
function clickDelete() {
var $tr = $(this).parent().parent()
var name = $tr.children(':first').html()
if (confirm('确定删除' + name + '吗?')) {
$tr.remove()
}
return false
}
script>
body>
html>
2、jQuery方式2-改进(使用了事件委托)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加删除记录练习title>
<link rel="stylesheet" type="text/css" href="../css/css.css" />
head>
<body>
<table id="employeeTable">
<tr>
<th>Nameth>
<th>Emailth>
<th>Salaryth>
<th> th>
tr>
<tr>
<td>Tomtd>
<td>[email protected]td>
<td>5000td>
<td><a href="deleteEmp?id=001">Deletea>td>
tr>
<tr>
<td>Jerrytd>
<td>[email protected]td>
<td>8000td>
<td><a href="deleteEmp?id=002">Deletea>td>
tr>
<tr>
<td>Bobtd>
<td>[email protected]td>
<td>10000td>
<td><a href="deleteEmp?id=003">Deletea>td>
tr>
table>
<div id="formDiv">
<h4>添加新员工h4>
<table>
<tr>
<td class="word">name:td>
<td class="inp">
<input type="text" name="empName" id="empName" />
td>
tr>
<tr>
<td class="word">email:td>
<td class="inp">
<input type="text" name="email" id="email" />
td>
tr>
<tr>
<td class="word">salary:td>
<td class="inp">
<input type="text" name="salary" id="salary" />
td>
tr>
<tr>
<td colspan="2" align="center">
<button id="addEmpButton" value="abc">
Submit
button>
td>
tr>
table>
div>
<script type="text/javascript" src="jquery-1.10.1.js">script>
<script type="text/javascript">
/*
1. 添加
2. 删除
*/
$('#addEmpButton').click(function() {
//1. 收集输入的数据
var $empName = $('#empName')
var $email = $('#email')
var $salary = $('#salary')
var empName = $empName.val()
var email = $email.val()
var salary = $salary.val()
//2. 生成对应的标签结构, 并插入#employeeTable的tbody中
/*
Bob
[email protected]
10000
Delete
*/
var $xxx = $(' ')
.append('' + empName + ' ') // 拼串
.append('' + email + ' ')
.append('' + salary + ' ')
.append(' + Date.now() + '>Delete ')
.appendTo('#employeeTable>tbody')
//3. 清除输入
$empName.val('')
$email.val('')
$salary.val('')
})
// 通过table实现对所有a的click事件委托
$('#employeeTable').delegate('a', 'click', clickDelete)
/*
点击删除的回调函数
*/
function clickDelete() {
var $tr = $(this).parent().parent()
var name = $tr.children(':first').html()
if (confirm('确定删除' + name + '吗?')) {
$tr.remove()
}
return false
}
script>
body>
html>
3、js原生方式
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加删除记录练习title>
<link rel="stylesheet" type="text/css" href="../css/css.css" />
head>
<body>
<table id="employeeTable">
<tr>
<th>Nameth>
<th>Emailth>
<th>Salaryth>
<th> th>
tr>
<tr>
<td>Tomtd>
<td>[email protected]td>
<td>5000td>
<td><a href="deleteEmp?id=001">Deletea>td>
tr>
<tr>
<td>Jerrytd>
<td>[email protected]td>
<td>8000td>
<td><a href="deleteEmp?id=002">Deletea>td>
tr>
<tr>
<td>Bobtd>
<td>[email protected]td>
<td>10000td>
<td><a href="deleteEmp?id=003">Deletea>td>
tr>
table>
<div id="formDiv">
<h4>添加新员工h4>
<table>
<tr>
<td class="word">name: td>
<td class="inp">
<input type="text" name="empName" id="empName" />
td>
tr>
<tr>
<td class="word">email: td>
<td class="inp">
<input type="text" name="email" id="email" />
td>
tr>
<tr>
<td class="word">salary: td>
<td class="inp">
<input type="text" name="salary" id="salary" />
td>
tr>
<tr>
<td colspan="2" align="center">
<button id="addEmpButton" value="abc">
Submit
button>
td>
tr>
table>
div>
<script type="text/javascript">
/*
功能说明:
1. 点击'Submit', 根据输入的信息在表单中生成一行员工信息
2. 点击Delete链接, 提示删除当前行信息, 点击确定后删除信息
技术要点:
1. DOM查询
2. 绑定事件监听
3. DOM增删改
5. 取消事件的默认行为
*/
function removeTr(){
var trNode = this.parentNode.parentNode;
var tds = trNode.getElementsByTagName("td");
var nameStr = tds[0].firstChild.nodeValue;
var flag = confirm("真的要删除" + nameStr + "的信息吗?");
if(flag){
trNode.parentNode.removeChild(trNode);
}
return false;
}
window.onload = function(){
//目标1:点击Delete删除记录
var aEles = document.getElementsByTagName("a");
for(var i = 0;i < aEles.length;i++){
aEles[i].onclick = removeTr;
}
//目标2:点击Submit增加记录
var subBtn = document.getElementById("addEmpButton");
subBtn.onclick = function(){
var nameText = trim(document.getElementById("empName").value);
var emailText = trim(document.getElementById("email").value);
var salaryText = trim(document.getElementById("salary").value);
document.getElementById("empName").value = nameText;
document.getElementById("email").value = emailText;
document.getElementById("salary").value = salaryText;
if(nameText == "" || emailText == "" || salaryText == ""){
alert("您输入的内容不完整");
return ;
}
//组装节点
var nameTd = document.createElement("td");
nameTd.appendChild(document.createTextNode(nameText));
var emailTd = document.createElement("td");
emailTd.appendChild(document.createTextNode(emailText));
var salaryTd = document.createElement("td");
salaryTd.appendChild(document.createTextNode(salaryText));
var aTd = document.createElement("td");
var aNewEle = document.createElement("a");
aNewEle.href = "deleteEmp?id=XXX";
aNewEle.appendChild(document.createTextNode("Delete"));
aNewEle.onclick = removeTr;
aTd.appendChild(aNewEle);
var trNode = document.createElement("tr");
trNode.appendChild(nameTd);
trNode.appendChild(emailTd);
trNode.appendChild(salaryTd);
trNode.appendChild(aTd);
var empTable = document.getElementById("employeeTable");
empTable.appendChild(trNode);
}
function trim(str){
var reg = /^\s*|\s*$/g;
return str.replace(reg,"");
}
}
script>
body>
html>
22、事件处理
<html>
<head>
<meta charset="UTF-8">
<title>18_事件绑定与解绑title>
head>
<style type="text/css">
* {
margin: 0px;
}
.out {
position: absolute;
width: 200px;
height: 200px;
top: 20px;
left: 10px;
background: blue;
}
.inner {
position: absolute;
width: 100px;
height: 100px;
top: 50px;
background: red;
}
.divBtn {
position: absolute;
top: 250px;
}
style>
<body style="height: 2000px;">
<div class="out">
外部DIV
<div class="inner">内部divdiv>
div>
<div class='divBtn'>
<button id="btn1">取消绑定所有事件button>
<button id="btn2">取消绑定mouseover事件button>
<button id="btn3">测试事件坐标button>
<a href="http://www.baidu.com" id="test4">百度一下a>
div>
<script type="text/javascript">
/*
需求:
1. 给.out绑定点击监听(用两种方法绑定)
2. 给.inner绑定鼠标移入和移出的事件监听(用3种方法绑定)
3. 点击btn1解除.inner上的所有事件监听
4. 点击btn2解除.inner上的mouseover事件
5. 点击btn3得到事件坐标
6. 点击.inner区域, 外部点击监听不响应
7. 点击链接, 如果当前时间是偶数不跳转
*/
//1. 给.out绑定点击监听(用两种方法绑定)
/*$('.out').click(function () {
console.log('click out')
})*/
$('.out').on('click', function() {
console.log('on click out')
})
//2. 给.inner绑定鼠标移入和移出的事件监听(用3种方法绑定)
/*
$('.inner')
.mouseenter(function () { // 进入
console.log('进入')
})
.mouseleave(function () { // 离开
console.log('离开')
})
*/
/*
$('.inner')
.on('mouseenter', function () {
console.log('进入2')
})
.on('mouseleave', function () {
console.log('离开2')
})
*/
$('.inner').hover(function() {
console.log('进入3')
}, function() {
console.log('离开3')
})
//3. 点击btn1解除.inner上的所有事件监听
$('#btn1').click(function() {
$('.inner').off()
})
//4. 点击btn2解除.inner上的mouseenter事件
$('#btn2').click(function() {
$('.inner').off('mouseenter')
})
//5. 点击btn3得到事件坐标
$('#btn3').click(function(event) { // event事件对象
console.log(event.offsetX, event.offsetY) // 原点为事件元素的左上角
console.log(event.clientX, event.clientY) // 原点为窗口的左上角
console.log(event.pageX, event.pageY) // 原点为页面的左上角
})
//6. 点击.inner区域, 外部点击监听不响应
$('.inner').click(function(event) {
console.log('click inner')
//停止事件冒泡
event.stopPropagation()
})
//7. 点击链接, 如果当前时间是偶数不跳转
$('#test4').click(function(event) {
if (Date.now() % 2 === 0) {
event.preventDefault()
}
})
script>
body>
html>
23、区别mouseover与mouseenter
<html>
<head>
<meta charset="UTF-8">
<title>19_事件切换title>
head>
<style type="text/css">
* {
margin: 0px;
}
.div1 {
position: absolute;
width: 200px;
height: 200px;
top: 50px;
left: 10px;
background: olive;
}
.div2 {
position: absolute;
width: 100px;
height: 100px;
top: 50px;
background: red;
}
.div3 {
position: absolute;
width: 200px;
height: 200px;
top: 50px;
left: 230px;
background: olive;
}
.div4 {
position: absolute;
width: 100px;
height: 100px;
top: 50px;
background: yellow;
}
.divText {
position: absolute;
top: 330px;
left: 10px;
}
style>
<body>
<div class="divText">
区分鼠标的事件
div>
<div class="div1">
div1.....
<div class="div2">div2....div>
div>
<div class="div3">
div3.....
<div class="div4">div4....div>
div>
<script src="js/jquery-1.10.1.js" type="text/javascript">script>
<script type="text/javascript">
$('.div1')
.mouseover(function() {
console.log('mouseover 进入')
})
.mouseout(function() {
console.log('mouseout 离开')
})
$('.div3')
.mouseenter(function() {
console.log('mouseenter 进入')
})
.mouseleave(function() {
console.log('mouseleave 离开')
})
script>
body>
html>
24、事件委托
<html>
<head>
<meta charset="UTF-8">
<title>20_事件委托2title>
head>
<body>
<ul>
<li>1111li>
<li>2222li>
<li>3333li>
<li>4444li>
ul>
<li>22222li>
<br>
<button id="btn1">添加新的libutton>
<button id="btn2">删除ul上的事件委托的监听器button>
<script src="js/jquery-1.10.1.js">script>
<script>
// 设置事件委托
$('ul').delegate('li', 'click', function() {
// console.log(this)
this.style.background = 'red'
})
$('#btn1').click(function() {
$('ul').append('新增的li.... ')
})
$('#btn2').click(function() {
// 移除事件委托
$('ul').undelegate('click')
})
script>
body>
html>
25、轮播图
1、原生
<html>
<head>
<meta charset="UTF-8">
<title>焦点轮播图title>
<style type="text/css">
/*去除内边距,没有链接下划线*/
* {
margin: 0;
padding: 0;
text-decoration: none;
}
/*让
body {
padding: 20px;
}
/*最外围的div*/
#container {
width: 600px;
height: 400px;
overflow: hidden;
position: relative;
/*相对定位*/
margin: 0 auto;
}
/*包含所有图片的*/
#list {
width: 4200px;
/*7张图片的宽*/
height: 400px;
position: absolute;
/*绝对定位*/
z-index: 1;
/*???*/
}
/*所有的图片*/
#list img {
float: left;
/*浮在左侧*/
}
/*包含所有圆点按钮的*/
#buttons {
position: absolute;
height: 10px;
width: 100px;
z-index: 2;
bottom: 20px;
left: 250px;
}
/*所有的圆点*/
#buttons span {
cursor: pointer;
float: left;
border: 1px solid #fff;
width: 10px;
height: 10px;
border-radius: 50%;
background: #333;
margin-right: 5px;
}
/*第一个*/
#buttons .on {
background: orangered;
}
/*切换图标*/
.arrow {
cursor: pointer;
display: none;
line-height: 39px;
text-align: center;
font-size: 36px;
font-weight: bold;
width: 40px;
height: 40px;
position: absolute;
z-index: 2;
top: 180px;
background-color: RGBA(0, 0, 0, 0.3);
color: #fff;
}
/*鼠标移到切换图标上时*/
.arrow:hover {
background-color: RGBA(0, 0, 0, 0.7);
}
/*鼠标移到整个div区域时*/
#container:hover .arrow {
display: block;
/*显示*/
}
/*上一个切换图标的左外边距*/
#prev {
left: 20px;
}
/*下一个切换图标的右外边距*/
#next {
right: 20px;
}
style>
head>
<body>
<div id="container">
<div id="list" style="left: -600px;">
<img src="img/5.jpg" alt="1" />
<img src="img/1.jpg" alt="1" />
<img src="img/2.jpg" alt="2" />
<img src="img/3.jpg" alt="3" />
<img src="img/4.jpg" alt="4" />
<img src="img/5.jpg" alt="5" />
<img src="img/1.jpg" alt="5" />
div>
<div id="buttons">
<span index="1" class="on">span>
<span index="2">span>
<span index="3">span>
<span index="4">span>
<span index="5">span>
div>
<a href="javascript:;" id="prev" class="arrow"><a>
<a href="javascript:;" id="next" class="arrow">>a>
div>
<script type="text/javascript">
/*
功能说明:
1. 点击向右(左)的图标, 平滑切换到下(上)一页
2. 无限循环切换: 第一页的上一页为最后页, 最后一页的下一页是第一页
3. 每隔3s自动滑动到下一页
4. 当鼠标进入图片区域时, 自动切换停止, 当鼠标离开后,又开始自动切换
5. 切换页面时, 下面的圆点也同步更新
6. 点击圆点图标切换到对应的页
*/
/**
* 根据id得到对应的标签对象
* @param {Object} id
*/
function $(id) {
return document.getElementById(id);
}
/**
* 给指定id对应的元素绑定点击监听
* @param {Object} id
* @param {Object} callback
*/
function click(id, callback) {
$(id).onclick = callback;
}
window.onload = function() {
var listDiv = $("list");
var totalTime = 400; //换页的总时间
var intervalTime = 20; //移动的间隔时间
var intervalId; //循环定时器的id(翻页中的不移动)
var imgCount = 5; //图片的个数
var moveing = false; //是否正在移动中
var index = 0; //当前显示图片的下标(从0开始到imgCount-1)
var buttonSpans = $("buttons").children; //所有标识圆点标签的集合
var containerDiv = $("container");
var intervalId2; //循环定时器的id(自动翻页)
//给下一页绑定点击监听
click("next", function() {
//切换到下一页
nextPage(true);
});
//给上一页绑定点击监听
click("prev", function() {
//切换到上一页
nextPage(false);
});
//给所有的提示圆点绑定点击监听
clickButtons();
//启动定时自动翻页
autoNextPage();
//给容器div绑定鼠标移入的监听: 停止自动翻页
containerDiv.onmouseover = function() {
clearInterval(intervalId2);
}
//给容器div绑定鼠标移出的监听: 启动自动翻页
containerDiv.onmouseout = function() {
autoNextPage();
};
/**
* 启动定时自动翻页
*/
function autoNextPage() {
intervalId2 = setInterval(function() {
nextPage(true);
}, 3000);
}
/**
* 切换到下一页/上一页
* true 下
* false 上
* index 目标页
* @param {Object} next true
*/
function nextPage(next) {
//如果正在移动, 直接结束
if (moveing) {
return;
}
//标识正在移动
moveing = true;
//需要进行的总偏移量
var offset;
if (typeof next === 'boolean') {
offset = next ? -600 : 600;
} else {
offset = -600 * (next - index);
}
//var offset = next ? -600 : 600;
//每个小移动需要做的偏移量
var itemOffset = offset / (totalTime / intervalTime);
//切换完成时div的left的坐标
var targetLeft = listDiv.offsetLeft + offset;
//循环定时器
intervalId = setInterval(function() {
//var currentLeft = listDiv.offsetLeft;
//得到当前这次偏移的样式left坐标
var left = listDiv.offsetLeft + itemOffset;
//如果已经到达目标位置
if (left == targetLeft) {
//移除定时器
clearInterval(intervalId);
//如果当前到达的是最左边的图片, 跳转到右边第二张图片的位置
if (left == 0) {
left = -imgCount * 600;
} else if (left == -600 * (imgCount + 1)) { //如果当前到达的是最右边的图片, 跳转到左边第二张图片的位置
left = -600;
}
//标识没有移动了
moveing = false;
}
//指定div新的left坐标
listDiv.style.left = left + "px";
}, intervalTime);
//更新标识圆点
updateButtons(next);
}
/**
* 更新标识圆点
* @param {Object} next
*/
function updateButtons(next) {
//将当前的圆点更新为一般圆点
buttonSpans[index].removeAttribute("class");
//计算出目标圆点的下标
var targetIndex;
if (typeof next == 'boolean') {
if (next) {
targetIndex = index + 1;
if (targetIndex == imgCount) {
targetIndex = 0;
}
} else {
targetIndex = index - 1;
if (targetIndex == -1) {
targetIndex = imgCount - 1;
}
}
} else {
targetIndex = next;
}
//将标圆点的下标更新为当前下标
index = targetIndex;
//将目标圆点设置为当前圆点
buttonSpans[index].className = 'on';
}
/**
* 给所有的圆点设置点击监听
*/
function clickButtons() {
for (var i = 0, length = buttonSpans.length; i < length; i++) {
buttonSpans[i].index = i;
buttonSpans[i].onclick = function() {
nextPage(this.index);
};
/*
(function (index) {
buttonSpans[index].onclick = function () {
nextPage(index);
};
})(i);
*/
}
}
};
script>
body>
html>
2、jQuery
html代码
<html>
<head>
<meta charset="UTF-8">
<title>焦点轮播图title>
<style type="text/css">
/*去除内边距,没有链接下划线*/
* {
margin: 0;
padding: 0;
text-decoration: none;
}
/*让
body {
padding: 20px;
}
/*最外围的div*/
#container {
width: 600px;
height: 400px;
overflow: hidden;
position: relative;
/*相对定位*/
margin: 0 auto;
}
/*包含所有图片的*/
#list {
width: 4200px;
/*7张图片的宽: 7*600 */
height: 400px;
position: absolute;
/*绝对定位*/
z-index: 1;
}
/*所有的图片*/
#list img {
float: left;
/*浮在左侧*/
}
/*包含所有圆点按钮的*/
#pointsDiv {
position: absolute;
height: 10px;
width: 100px;
z-index: 2;
bottom: 20px;
left: 250px;
}
/*所有的圆点*/
#pointsDiv span {
cursor: pointer;
float: left;
border: 1px solid #fff;
width: 10px;
height: 10px;
border-radius: 50%;
background: #333;
margin-right: 5px;
}
/*第一个*/
#pointsDiv .on {
background: orangered;
}
/*切换图标*/
.arrow {
cursor: pointer;
display: none;
line-height: 39px;
text-align: center;
font-size: 36px;
font-weight: bold;
width: 40px;
height: 40px;
position: absolute;
z-index: 2;
top: 180px;
background-color: RGBA(0, 0, 0, 0.3);
color: #fff;
}
/*鼠标移到切换图标上时*/
.arrow:hover {
background-color: RGBA(0, 0, 0, 0.7);
}
/*鼠标移到整个div区域时*/
#container:hover .arrow {
display: block;
/*显示*/
}
/*上一个切换图标的左外边距*/
#prev {
left: 20px;
}
/*下一个切换图标的右外边距*/
#next {
right: 20px;
}
style>
head>
<body>
<div id="container">
<div id="list" style="left: -600px;">
<img src="../img/5.jpg" alt="5" />
<img src="../img/1.jpg" alt="1" />
<img src="../img/2.jpg" alt="2" />
<img src="../img/3.jpg" alt="3" />
<img src="../img/4.jpg" alt="4" />
<img src="../img/5.jpg" alt="5" />
<img src="../img/1.jpg" alt="1" />
div>
<div id="pointsDiv">
<span index="1" class="on">span>
<span index="2">span>
<span index="3">span>
<span index="4">span>
<span index="5">span>
div>
<a href="javascript:;" id="prev" class="arrow"><a>
<a href="javascript:;" id="next" class="arrow">>a>
div>
<script type="text/javascript" src="../js/jquery-1.10.1.js">script>
<script type="text/javascript" src="../js/app.js">script>
body>
html>
js代码
/*
功能说明:
1. 点击向右(左)的图标, 平滑切换到下(上)一页
2. 无限循环切换: 第一页的上一页为最后页, 最后一页的下一页是第一页
3. 每隔3s自动滑动到下一页
4. 当鼠标进入图片区域时, 自动切换停止, 当鼠标离开后,又开始自动切换
5. 切换页面时, 下面的圆点也同步更新
6. 点击圆点图标切换到对应的页
bug: 快速点击时, 翻页不正常
*/
$(function () {
var $container = $('#container')
var $list = $('#list')
var $points = $('#pointsDiv>span')
var $prev = $('#prev')
var $next = $('#next')
var PAGE_WIDTH = 600 //一页的宽度
var TIME = 400 // 翻页的持续时间
var ITEM_TIME = 20 // 单元移动的间隔时间
var imgCount = $points.length
var index = 0 //当前下标
var moving = false // 标识是否正在翻页(默认没有)
// 1. 点击向右(左)的图标, 平滑切换到下(上)一页
$next.click(function () {
// 平滑翻到下一页
nextPage(true)
})
$prev.click(function () {
// 平滑翻到上一页
nextPage(false)
})
// 3. 每隔3s自动滑动到下一页
var intervalId = setInterval(function () {
nextPage(true)
}, 1000)
// 4. 当鼠标进入图片区域时, 自动切换停止, 当鼠标离开后,又开始自动切换
$container.hover(function () {
// 清除定时器
clearInterval(intervalId)
}, function () {
intervalId = setInterval(function () {
nextPage(true)
}, 1000)
})
// 6. 点击圆点图标切换到对应的页
$points.click(function () {
// 目标页的下标
var targetIndex = $(this).index()
// 只有当点击的不是当前页的圆点时才翻页
if(targetIndex!=index) {
nextPage(targetIndex)
}
})
/**
* 平滑翻页
* @param next
* true: 下一页
* false: 上一页
* 数值: 指定下标页
*/
function nextPage (next) {
/*
总的时间: TIME=400
单元移动的间隔时间: ITEM_TIME = 20
总的偏移量: offset
单元移动的偏移量: itemOffset = offset/(TIME/ITEM_TIME)
启动循环定时器不断更新$list的left, 到达目标处停止停止定时器
*/
//如果正在翻页, 直接结束
if(moving) { //已经正在翻页中
return
}
moving = true // 标识正在翻页
// 总的偏移量: offset
var offset = 0
// 计算offset
if(typeof next==='boolean') {
offset = next ? -PAGE_WIDTH : PAGE_WIDTH
} else {
offset = -(next-index)* PAGE_WIDTH
}
// 计算单元移动的偏移量: itemOffset
var itemOffset = offset/(TIME/ITEM_TIME)
// 得到当前的left值
var currLeft = $list.position().left
// 计算出目标处的left值
var targetLeft = currLeft + offset
// 启动循环定时器不断更新$list的left, 到达目标处停止停止定时器
var intervalId = setInterval(function () {
// 计算出最新的currLeft
currLeft += itemOffset
if(currLeft===targetLeft) { // 到达目标位置
// 清除定时器
clearInterval(intervalId)
// 标识翻页停止
moving = false
// 如果到达了最右边的图片(1.jpg), 跳转到最左边的第2张图片(1.jpg)
if(currLeft===-(imgCount+1) * PAGE_WIDTH) {
currLeft = -PAGE_WIDTH
} else if(currLeft===0){
// 如果到达了最左边的图片(5.jpg), 跳转到最右边的第2张图片(5.jpg)
currLeft = -imgCount * PAGE_WIDTH
}
}
// 设置left
$list.css('left', currLeft)
}, ITEM_TIME)
// 更新圆点
updatePoints(next)
}
/**
* 更新圆点
* @param next
*/
function updatePoints (next) {
// 计算出目标圆点的下标targetIndex
var targetIndex = 0
if(typeof next === 'boolean') {
if(next) {
targetIndex = index + 1 // [0, imgCount-1]
if(targetIndex===imgCount) {// 此时看到的是1.jpg-->第1个圆点
targetIndex = 0
}
} else {
targetIndex = index - 1
if(targetIndex===-1) { // 此时看到的是5.jpg-->第5个圆点
targetIndex = imgCount-1
}
}
} else {
targetIndex = next
}
// 将当前index的的class移除
// $points.eq(index).removeClass('on')
$points[index].className = ''
// 给目标圆点添加class='on'
// $points.eq(targetIndex).addClass('on')
$points[targetIndex].className = 'on'
// 将index更新为targetIndex
index = targetIndex
}
})
26、淡入淡出效果
<html>
<head>
<meta charset="UTF-8">
<title>21_淡入淡出title>
head>
<style type="text/css">
* {
margin: 0px;
}
.div1 {
position: absolute;
width: 200px;
height: 200px;
top: 50px;
left: 10px;
background: red;
}
style>
<body>
<button id="btn1">慢慢淡出button>
<button id="btn2">慢慢淡入button>
<button id="btn3">淡出/淡入切换button>
<div class="div1">
div>
<script src="js/jquery-1.10.1.js" type="text/javascript">script>
<script type="text/javascript">
/*
需求:
1. 点击btn1, 慢慢淡出
* 无参
* 有参
* 字符串参数
* 数字参数
2. 点击btn3, 慢慢淡入
3. 点击btn3, 淡出/淡入切换,动画结束时提示“动画结束了”
*/
var $div1 = $('.div1')
$('#btn1').click(function() {
// $div1.fadeOut()
// $div1.fadeOut('slow')
$div1.fadeOut(1000, function() {
alert('动画完成了!!!')
})
})
$('#btn2').click(function() {
$div1.fadeIn()
})
$('#btn3').click(function() {
$div1.fadeToggle()
})
script>
body>
html>
27、滑动
<html>
<head>
<meta charset="UTF-8">
<title>22_滑动title>
head>
<style type="text/css">
* {
margin: 0px;
}
.div1 {
position: absolute;
width: 200px;
height: 200px;
top: 50px;
left: 10px;
background: red;
}
style>
<body>
<button id="btn1">慢慢收缩button>
<button id="btn2">慢慢展开button>
<button id="btn3">收缩/展开切换button>
<div class="div1">
div>
<script src="js/jquery-1.10.1.js" type="text/javascript">script>
<script type="text/javascript">
/*
需求:
1. 点击btn1, 向上滑动
2. 点击btn2, 向下滑动
3. 点击btn3, 向上/向下切换
*/
var $div1 = $('.div1')
// 1. 点击btn1, 向上滑动
$('#btn1').click(function() {
$div1.slideUp(3000)
})
// 2. 点击btn2, 向下滑动
$('#btn2').click(function() {
$div1.slideDown()
})
// 3. 点击btn3, 向上/向下切换
$('#btn3').click(function() {
$div1.slideToggle()
})
script>
body>
html>
28、显示与隐藏
<html>
<head>
<meta charset="UTF-8">
<title>23_显示与隐藏title>
head>
<style type="text/css">
* {
margin: 0px;
}
.div1 {
position: absolute;
width: 200px;
height: 200px;
top: 50px;
left: 10px;
background: red;
display: none;
}
style>
<body>
<button id="btn1">瞬间显示button>
<button id="btn2">慢慢显示button>
<button id="btn3">慢慢隐藏button>
<button id="btn4">显示隐藏切换button>
<div class="div1">
div>
<script src="js/jquery-1.10.1.js" type="text/javascript">script>
<script type="text/javascript">
/*
需求:
1. 点击btn1, 立即显示
2. 点击btn2, 慢慢显示
3. 点击btn3, 慢慢隐藏
4. 点击btn4, 切换显示/隐藏
*/
var $div1 = $('.div1')
//1. 点击btn1, 立即显示
$('#btn1').click(function() {
$div1.show()
})
//2. 点击btn2, 慢慢显示
$('#btn2').click(function() {
$div1.show(1000)
})
//3. 点击btn3, 慢慢隐藏
$('#btn3').click(function() {
$div1.hide(1000)
})
//4. 点击btn4, 切换显示/隐藏
$('#btn4').click(function() {
$div1.toggle(1000)
})
script>
body>
html>
29、自定义动画
<html>
<head>
<meta charset="UTF-8">
<title>24_自定义动画title>
<style type="text/css">
* {
margin: 0px;
}
.div1 {
position: absolute;
width: 100px;
height: 100px;
top: 50px;
left: 300px;
background: red;
}
style>
head>
<body>
<button id="btn1">逐渐扩大button>
<button id="btn2">移动到指定位置button>
<button id="btn3">移动指定距离button>
<button id="btn4">停止动画button>
<div class="div1">
哈哈哈哈哈哈哈哈
div>
<script src="js/jquery-1.10.1.js" type="text/javascript">script>
<script type="text/javascript">
/*
需求:
1. 逐渐扩大
1). 宽/高都扩为200px
2). 宽先扩为200px, 高后扩为200px
2. 移动到指定位置
1).移动到(500, 100)处
2).移动到(100, 20)处
3.移动指定的距离
1). 移动距离为(100, 50)
2). 移动距离为(-100, -20)
4. 停止动画
*/
var $div1 = $('.div1')
/*
1. 逐渐扩大
1). 宽/高都扩为200px
2). 宽先扩为200px, 高后扩为200px
*/
$('#btn1').click(function() {
/*
$div1.animate({
width: 200,
height: 200
}, 1000)
*/
$div1
.animate({
width: 200
}, 1000)
.animate({
height: 200
}, 1000)
})
/*
2. 移动到指定位置
1).移动到(500, 100)处
2).移动到(100, 20)处
*/
$('#btn2').click(function() {
// 1).移动到(500, 100)处
/*
$div1.animate({ // 向右下移动
left: 500,
top: 100
}, 1000)
*/
// 2).移动到(100, 20)处
$div1.animate({ // 向左上移动
left: 100, // 300
top: 20 // 50
}, 1000)
})
/*
3.移动指定的距离
1). 移动距离为(100, 50)
2). 移动距离为(-100, -20)
*/
$('#btn3').click(function() {
// 1). 移动距离为(100, 50)
/*$div1.animate({
left: '+=100',
top: '+=50'
}, 1000)*/
// 2). 移动距离为(-100, -20)
$div1.animate({
left: '-=100',
top: '-=20'
}, 3000)
})
$('#btn4').click(function() {
$div1.stop()
})
script>
body>
html>
30、导航动态显示效果
<html lang="en">
<head>
<meta charset="UTF-8">
<title>04_导航动态显示效果title>
<style rel="stylesheet">
* {
margin: 0;
padding: 0;
word-wrap: break-word;
word-break: break-all;
}
body {
background: #FFF;
color: #333;
font: 12px/1.6em Helvetica, Arial, sans-serif;
}
a {
color: #0287CA;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
ul, li {
list-style: none;
}
img {
border: none;
}
h1, h2, h3, h4, h5, h6 {
font-size: 1em;
}
html {
overflow: -moz-scrollbars-vertical; /* 在Firefox下始终显示滚动条*/
}
#navigation {
width: 784px;
padding: 8px;
margin: 8px auto;
background: #3B5998;
height: 18px;
}
#navigation ul li {
float: left;
margin-right: 14px;
position: relative;
z-index: 100;
}
#navigation ul li a {
display: block;
padding: 0 8px;
background: #EEEEEE;
font-weight: 700;
}
#navigation ul li a:hover {
background: none;
color: #fff;
}
#navigation ul li ul {
background-color: #88C366;
position: absolute;
width: 80px;
overflow: hidden;
display: none;
}
#navigation ul li ul li {
border-bottom: 1px solid #BBB;
text-align: left;
width: 100%;
}
style>
head>
<body>
<div id="navigation">
<ul>
<li><a href="#">首 页a>li>
<li><a href="#">衬 衫a>
<ul>
<li><a href="#">短袖衬衫a>li>
<li><a href="#">长袖衬衫a>li>
<li><a href="#">无袖衬衫a>li>
ul>
li>
<li><a href="#">卫 衣a>
<ul>
<li><a href="#">开襟卫衣a>li>
<li><a href="#">套头卫衣a>li>
ul>
li>
<li>
<a href="#">裤 子a>
<ul>
<li><a href="#">休闲裤a>li>
<li><a href="#">卡其裤a>li>
<li><a href="#">牛仔裤a>li>
<li><a href="#">短裤a>li>
ul>
li>
<li><a href="#">联系我们a>li>
ul>
div>
<script type="text/javascript" src="jquery-1.10.1.js">script>
<script type="text/javascript">
$('#navigation>ul>li:has(ul)').hover(function() {
//动画展开
$(this).children('ul').stop(true).slideDown()
}, function() {
// 动画收缩
$(this).children('ul').stop(true).slideUp()
})
script>
body>
html>
三、多库并存
<html>
<head>
<meta charset="UTF-8">
<title>26_多库共存title>
<style type="text/css">
* {
margin: 0px;
}
.div1 {
position: absolute;
width: 100px;
height: 100px;
top: 50px;
left: 10px;
background: red;
}
style>
head>
<body>
<script type="text/javascript" src="js/myLib.js">script>
<script type="text/javascript" src="js/jquery-1.10.1.js">script>
<script type="text/javascript">
// 释放$的使用权
jQuery.noConflict()
// 调用myLib中的$
$()
// 要想使用jQuery的功能, 只能使用jQuery
jQuery(function() {
console.log('文档加载完成')
})
console.log('+++++')
script>
body>
html>
myLib.js
(function () {
window.$ = function () {
console.log('my lib $()...')
}
})()
四、onload与ready
<html lang="en">
<head>
<meta charset="UTF-8">
<title>window.onload与$(document).ready()title>
head>
<body>
<h1>测试window.onload与$(document).ready()h1>
<img id="logo" src="https://gss0.bdstatic.com/5bVWsj_p_tVS5dKfpU_Y_D3/res/r/image/2017-05-19/6fec71d56242b74eb24b4ac80b817eac.png">
<script type="text/javascript" src="js/jquery-1.10.1.js">script>
<script type="text/javascript">
/*
需求:
1. 直接打印img的宽度,观察其值
2. 在 $(function(){}) 中 打印 img 的宽度
3. 在 window.onload 中打印宽度
4. 在 img 加载完成后打印宽度
*/
// 1. 直接打印img的宽度,观察其值
console.log('直接', $('#logo').width())
window.onload = function() {
console.log('onload', $('#logo').width())
}
window.onload = function() {
console.log('onload2', $('#logo').width())
}
$(function() {
console.log('ready', $('#logo').width())
})
$(function() {
console.log('ready2', $('#logo').width())
})
$('#logo').on('load', function() {
console.log('img load', $(this).width())
})
/*$(document).ready(function () {
})*/
script>
body>
html>
五、扩展插件
<html>
<head>
<meta charset="UTF-8">
<title>25_扩展插件title>
<style type="text/css">
* {
margin: 0px;
}
.div1 {
position: absolute;
width: 100px;
height: 100px;
top: 50px;
left: 10px;
background: red;
}
style>
head>
<body>
<input type="checkbox" name="items" value="足球" />足球
<input type="checkbox" name="items" value="篮球" />篮球
<input type="checkbox" name="items" value="羽毛球" />羽毛球
<input type="checkbox" name="items" value="乒乓球" />乒乓球
<br />
<input type="button" id="checkedAllBtn" value="全 选" />
<input type="button" id="checkedNoBtn" value="全不选" />
<input type="button" id="reverseCheckedBtn" value="反选" />
<script src="js/jquery-1.10.1.js" type="text/javascript">script>
<script type="text/javascript" src="js/my_jQuery-plugin.js">script>
<script type="text/javascript">
/*
需求:
1. 给 $ 添加4个工具方法:
* min(a, b) : 返回较小的值
* max(c, d) : 返回较大的值
* leftTrim() : 去掉字符串左边的空格
* rightTrim() : 去掉字符串右边的空格
2. 给jQuery对象 添加3个功能方法:
* checkAll() : 全选
* unCheckAll() : 全不选
* reverseCheck() : 全反选
*/
console.log($.min(3, 5), $.max(3, 5))
var string = ' my atguigu '
console.log('-----' + $.leftTrim(string) + '-----')
console.log('-----' + $.rightTrim(string) + '-----')
var $items = $(':checkbox[name=items]')
$('#checkedAllBtn').click(function() {
$items.checkAll()
})
$('#checkedNoBtn').click(function() {
$items.unCheckAll()
})
$('#reverseCheckedBtn').click(function() {
$items.reverseCheck()
})
script>
body>
html>
js文件
/*
需求:
1. 给 $ 添加4个工具方法:
* min(a, b) : 返回较小的值
* max(c, d) : 返回较大的值
* leftTrim() : 去掉字符串左边的空格
* rightTrim() : 去掉字符串右边的空格
2. 给jQuery对象 添加3个功能方法:
* checkAll() : 全选
* unCheckAll() : 全不选
* reverseCheck() : 全反选
*/
(function() {
// 扩展$的方法
$.extend({
min: function(a, b) {
return a < b ? a : b
},
max: function(a, b) {
return a > b ? a : b
},
leftTrim: function(str) {
return str.replace(/^\s+/, '')
},
rightTrim: function(str) {
return str.replace(/\s+$/, '')
}
})
// 扩展jQuery对象的方法
$.fn.extend({
checkAll: function() {
this.prop('checked', true) // this是jQuery对象
},
unCheckAll: function() {
this.prop('checked', false)
},
reverseCheck: function() {
// this是jQuery对象
this.each(function() {
// this是dom元素
this.checked = !this.checked
})
}
})
})()
六、jQuery插件-jQueryValidate
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Titletitle>
<style>
.error {
color: red;
}
style>
head>
<body>
<form id="myForm" action="xxx">
<p>用户名(必须, 最小6位): <input name="username" type="text" required minlength="6">p>
<p>密码(必须,6到8位): <input id="password" name="pwd1" type="password" required minlength="6" maxlength="8">p>
<p>确认密码(与密码相同): <input name="pwd2" type="password" equalTo="#password">p>
<p><input type="submit" value="注册">p>
form>
<script type="text/javascript" src="jquery-1.11.1.js">script>
<script type="text/javascript" src="jquery.validate.js">script>
<script type="text/javascript">
/*
声明式验证: 程序员只需要声明各种验证规则, 可以自定义验证错误信息
*/
//对此表单开户验证
$('#myForm').validate({
messages: {
username: {
required: '用户名是必须的',
minlength: '用户名至少为6位'
},
pwd1: {
required: '密码是必须的',
minlength: '密码至少为6位',
maxlength: '密码最多8位'
},
pwd2: {
equalTo: '必须与密码相同'
}
}
})
script>
body>
html>
官方示例
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery validation plug-in - main demotitle>
<link rel="stylesheet" href="css/screen.css">
<script src="../lib/jquery.js">script>
<script src="../dist/jquery.validate.js">script>
<script>
$.validator.setDefaults({
submitHandler: function() {
alert("submitted!");
}
});
$().ready(function() {
// validate the comment form when it is submitted
$("#commentForm").validate();
// validate signup form on keyup and submit
$("#signupForm").validate({
rules: {
firstname: "required",
lastname: "required",
username: {
required: true,
minlength: 2
},
password: {
required: true,
minlength: 5
},
confirm_password: {
required: true,
minlength: 5,
equalTo: "#password"
},
email: {
required: true,
email: true
},
topic: {
required: "#newsletter:checked",
minlength: 2
},
agree: "required"
},
messages: {
firstname: "Please enter your firstname",
lastname: "Please enter your lastname",
username: {
required: "Please enter a username",
minlength: "Your username must consist of at least 2 characters"
},
password: {
required: "Please provide a password",
minlength: "Your password must be at least 5 characters long"
},
confirm_password: {
required: "Please provide a password",
minlength: "Your password must be at least 5 characters long",
equalTo: "Please enter the same password as above"
},
email: "Please enter a valid email address",
agree: "Please accept our policy",
topic: "Please select at least 2 topics"
}
});
// propose username by combining first- and lastname
$("#username").focus(function() {
var firstname = $("#firstname").val();
var lastname = $("#lastname").val();
if (firstname && lastname && !this.value) {
this.value = firstname + "." + lastname;
}
});
//code to hide topic selection, disable for demo
var newsletter = $("#newsletter");
// newsletter topics are optional, hide at first
var inital = newsletter.is(":checked");
var topics = $("#newsletter_topics")[inital ? "removeClass" : "addClass"]("gray");
var topicInputs = topics.find("input").attr("disabled", !inital);
// show when newsletter is checked
newsletter.click(function() {
topics[this.checked ? "removeClass" : "addClass"]("gray");
topicInputs.attr("disabled", !this.checked);
});
});
script>
<style>
#commentForm {
width: 500px;
}
#commentForm label {
width: 250px;
}
#commentForm label.error, #commentForm input.submit {
margin-left: 253px;
}
#signupForm {
width: 670px;
}
#signupForm label.error {
margin-left: 10px;
width: auto;
display: inline;
}
#newsletter_topics label.error {
display: none;
margin-left: 103px;
}
style>
head>
<body>
<h1 id="banner"><a href="http://jqueryvalidation.org/">jQuery Validation Plugina> Demoh1>
<div id="main">
<p>Default submitHandler is set to display an alert into of submitting the formp>
<form class="cmxform" id="commentForm" method="get" action="">
<fieldset>
<legend>Please provide your name, email address (won't be published) and a commentlegend>
<p>
<label for="cname">Name (required, at least 2 characters)label>
<input id="cname" name="name" minlength="2" type="text" required>
p>
<p>
<label for="cemail">E-Mail (required)label>
<input id="cemail" type="email" name="email" required>
p>
<p>
<label for="curl">URL (optional)label>
<input id="curl" type="url" name="url">
p>
<p>
<label for="ccomment">Your comment (required)label>
<textarea id="ccomment" name="comment" required>textarea>
p>
<p>
<input class="submit" type="submit" value="Submit">
p>
fieldset>
form>
<form class="cmxform" id="signupForm" method="get" action="">
<fieldset>
<legend>Validating a complete formlegend>
<p>
<label for="firstname">Firstnamelabel>
<input id="firstname" name="firstname" type="text">
p>
<p>
<label for="lastname">Lastnamelabel>
<input id="lastname" name="lastname" type="text">
p>
<p>
<label for="username">Usernamelabel>
<input id="username" name="username" type="text">
p>
<p>
<label for="password">Passwordlabel>
<input id="password" name="password" type="password">
p>
<p>
<label for="confirm_password">Confirm passwordlabel>
<input id="confirm_password" name="confirm_password" type="password">
p>
<p>
<label for="email">Emaillabel>
<input id="email" name="email" type="email">
p>
<p>
<label for="agree">Please agree to our policylabel>
<input type="checkbox" class="checkbox" id="agree" name="agree">
p>
<p>
<label for="newsletter">I'd like to receive the newsletterlabel>
<input type="checkbox" class="checkbox" id="newsletter" name="newsletter">
p>
<fieldset id="newsletter_topics">
<legend>Topics (select at least two) - note: would be hidden when newsletter isn't selected, but is visible here for the demolegend>
<label for="topic_marketflash">
<input type="checkbox" id="topic_marketflash" value="marketflash" name="topic">Marketflash
label>
<label for="topic_fuzz">
<input type="checkbox" id="topic_fuzz" value="fuzz" name="topic">Latest fuzz
label>
<label for="topic_digester">
<input type="checkbox" id="topic_digester" value="digester" name="topic">Mailing list digester
label>
<label for="topic" class="error">Please select at least two topics you'd like to receive.label>
fieldset>
<p>
<input class="submit" type="submit" value="Submit">
p>
fieldset>
form>
<h3>Synthetic examplesh3>
<ul>
<li><a href="errorcontainer-demo.html">Error message containers in actiona>
li>
<li><a href="custom-messages-data-demo.html">Custom Messages as Element Dataa>
li>
<li><a href="radio-checkbox-select-demo.html">Radio and checkbox buttons and selectsa>
li>
<li><a href="ajaxSubmit-integration-demo.html">Integration with Form Plugin (AJAX submit)a>
li>
<li><a href="custom-methods-demo.html">Custom methods and message display.a>
li>
<li><a href="dynamic-totals.html">Dynamic formsa>
li>
<li><a href="themerollered.html">Forms styled with jQuery UI Themerollera>
li>
<li><a href="tinymce/">TinyMCE3 Demoa>
li>
<li><a href="tinymce4/">TinyMCE4 Demoa>
li>
<li><a href="file_input.html">File inputsa>
li>
<li><a href="jquerymobile.html">jQuery Mobile Form Validationa>
li>
<li><a href="errors-within-labels.html">Displaying Errors within Field Labelsa>
li>
<li><a href="requirejs/index.html">Loading via RequireJSa>
li>
ul>
<h3>Real-world examplesh3>
<ul>
<li><a href="cinema/">Retro Cinema Registrationa>li>
<li><a href="milk/">Remember The Milk signup forma>li>
<li><a href="marketo/">Marketo signup forma>li>
<li><a href="multipart/">Buy and Sell a House multipart forma>li>
<li><a href="captcha/">Remote captcha validationa>li>
ul>
div>
body>
html>
七、jQuery插件-jQueryUI
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Titletitle>
<link rel="stylesheet" href="css/jquery-ui.css">
head>
<body>
<h2>1. Accordion: 手风琴h2>
<div id="accordion">
<h3>Firsth3>
<div>Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.div>
<h3>Secondh3>
<div>Phasellus mattis tincidunt nibh.div>
<h3>Thirdh3>
<div>Nam dui erat, auctor a, dignissim quis.div>
div>
<h2>Autocompleteh2>
<div>
<input id="autocomplete" title="type "a"">
div>
<h2>3. Tabs: 选项卡h2>
<div id="tabs">
<ul>
<li><a href="#tabs-1">Firsta>li>
<li><a href="#tabs-2">Seconda>li>
<li><a href="#tabs-3">Thirda>li>
ul>
<div id="tabs-1">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat.div>
<div id="tabs-2">Phasellus mattis tincidunt nibh. Cras orci urna, blandit id, pretium vel, aliquet ornare, felis.
Maecenas scelerisque sem non nisl. Fusce sed lorem in enim dictum bibendum.div>
<div id="tabs-3">Nam dui erat, auctor a, dignissim quis, sollicitudin eu, felis. Pellentesque nisi urna, interdum
eget, sagittis et, consequat vestibulum, lacus. Mauris porttitor ullamcorper augue.div>
div>
<script type="text/javascript" src="js/jquery.js">script>
<script type="text/javascript" src="js/jquery-ui.js">script>
<script type="text/javascript">
// 1. Accordion: 手风琴
$('#accordion').accordion()
// 所有数据的数组
var dataSource = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
]
// 2. Autocomplete: 自动搜索匹配
$("#autocomplete").autocomplete({
source: dataSource // 数据源
});
// 3. Tabs: 选项卡
$('#tabs').tabs()
script>
body>
html>
官方示例
<html lang="us">
<head>
<meta charset="utf-8">
<title>jQuery UI Example Pagetitle>
<link href="jquery-ui.css" rel="stylesheet">
<style>
body{
font: 62.5% "Trebuchet MS", sans-serif;
margin: 50px;
}
.demoHeaders {
margin-top: 2em;
}
#dialog-link {
padding: .4em 1em .4em 20px;
text-decoration: none;
position: relative;
}
#dialog-link span.ui-icon {
margin: 0 5px 0 0;
position: absolute;
left: .2em;
top: 50%;
margin-top: -8px;
}
#icons {
margin: 0;
padding: 0;
}
#icons li {
margin: 2px;
position: relative;
padding: 4px 0;
cursor: pointer;
float: left;
list-style: none;
}
#icons span.ui-icon {
float: left;
margin: 0 4px;
}
.fakewindowcontain .ui-widget-overlay {
position: absolute;
}
select {
width: 200px;
}
style>
head>
<body>
<h1>Welcome to jQuery UI!h1>
<div class="ui-widget">
<p>This page demonstrates the widgets and theme you selected in Download Builder. Please make sure you are using them with a compatible jQuery version.p>
div>
<h1>YOUR COMPONENTS:h1>
<h2 class="demoHeaders">Accordionh2>
<div id="accordion">
<h3>Firsth3>
<div>Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.div>
<h3>Secondh3>
<div>Phasellus mattis tincidunt nibh.div>
<h3>Thirdh3>
<div>Nam dui erat, auctor a, dignissim quis.div>
div>
<h2 class="demoHeaders">Autocompleteh2>
<div>
<input id="autocomplete" title="type "a"">
div>
<h2 class="demoHeaders">Buttonh2>
<button id="button">A button elementbutton>
<form style="margin-top: 1em;">
<div id="radioset">
<input type="radio" id="radio1" name="radio"><label for="radio1">Choice 1label>
<input type="radio" id="radio2" name="radio" checked="checked"><label for="radio2">Choice 2label>
<input type="radio" id="radio3" name="radio"><label for="radio3">Choice 3label>
div>
form>
<h2 class="demoHeaders">Tabsh2>
<div id="tabs">
<ul>
<li><a href="#tabs-1">Firsta>li>
<li><a href="#tabs-2">Seconda>li>
<li><a href="#tabs-3">Thirda>li>
ul>
<div id="tabs-1">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.div>
<div id="tabs-2">Phasellus mattis tincidunt nibh. Cras orci urna, blandit id, pretium vel, aliquet ornare, felis. Maecenas scelerisque sem non nisl. Fusce sed lorem in enim dictum bibendum.div>
<div id="tabs-3">Nam dui erat, auctor a, dignissim quis, sollicitudin eu, felis. Pellentesque nisi urna, interdum eget, sagittis et, consequat vestibulum, lacus. Mauris porttitor ullamcorper augue.div>
div>
<h2 class="demoHeaders">Dialogh2>
<p><a href="#" id="dialog-link" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-newwin">span>Open Dialoga>p>
<h2 class="demoHeaders">Overlay and Shadow Classes <em>(not currently used in UI widgets)em>h2>
<div style="position: relative; width: 96%; height: 200px; padding:1% 2%; overflow:hidden;" class="fakewindowcontain">
<p>Lorem ipsum dolor sit amet, Nulla nec tortor. Donec id elit quis purus consectetur consequat. p><p>Nam congue semper tellus. Sed erat dolor, dapibus sit amet, venenatis ornare, ultrices ut, nisi. Aliquam ante. Suspendisse scelerisque dui nec velit. Duis augue augue, gravida euismod, vulputate ac, facilisis id, sem. Morbi in orci. p><p>Nulla purus lacus, pulvinar vel, malesuada ac, mattis nec, quam. Nam molestie scelerisque quam. Nullam feugiat cursus lacus.orem ipsum dolor sit amet, consectetur adipiscing elit. Donec libero risus, commodo vitae, pharetra mollis, posuere eu, pede. Nulla nec tortor. Donec id elit quis purus consectetur consequat. p><p>Nam congue semper tellus. Sed erat dolor, dapibus sit amet, venenatis ornare, ultrices ut, nisi. Aliquam ante. Suspendisse scelerisque dui nec velit. Duis augue augue, gravida euismod, vulputate ac, facilisis id, sem. Morbi in orci. Nulla purus lacus, pulvinar vel, malesuada ac, mattis nec, quam. Nam molestie scelerisque quam. p><p>Nullam feugiat cursus lacus.orem ipsum dolor sit amet, consectetur adipiscing elit. Donec libero risus, commodo vitae, pharetra mollis, posuere eu, pede. Nulla nec tortor. Donec id elit quis purus consectetur consequat. Nam congue semper tellus. Sed erat dolor, dapibus sit amet, venenatis ornare, ultrices ut, nisi. Aliquam ante. p><p>Suspendisse scelerisque dui nec velit. Duis augue augue, gravida euismod, vulputate ac, facilisis id, sem. Morbi in orci. Nulla purus lacus, pulvinar vel, malesuada ac, mattis nec, quam. Nam molestie scelerisque quam. Nullam feugiat cursus lacus.orem ipsum dolor sit amet, consectetur adipiscing elit. Donec libero risus, commodo vitae, pharetra mollis, posuere eu, pede. Nulla nec tortor. Donec id elit quis purus consectetur consequat. Nam congue semper tellus. Sed erat dolor, dapibus sit amet, venenatis ornare, ultrices ut, nisi. p>
<div class="ui-overlay"><div class="ui-widget-overlay">div><div class="ui-widget-shadow ui-corner-all" style="width: 302px; height: 152px; position: absolute; left: 50px; top: 30px;">div>div>
<div style="position: absolute; width: 280px; height: 130px;left: 50px; top: 30px; padding: 10px;" class="ui-widget ui-widget-content ui-corner-all">
<div class="ui-dialog-content ui-widget-content" style="background: none; border: 0;">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.p>
div>
div>
div>
<div id="dialog" title="Dialog Title">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.p>
div>
<h2 class="demoHeaders">Framework Icons (content color preview)h2>
<ul id="icons" class="ui-widget ui-helper-clearfix">
<li class="ui-state-default ui-corner-all" title=".ui-icon-carat-1-n"><span class="ui-icon ui-icon-carat-1-n">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-carat-1-ne"><span class="ui-icon ui-icon-carat-1-ne">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-carat-1-e"><span class="ui-icon ui-icon-carat-1-e">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-carat-1-se"><span class="ui-icon ui-icon-carat-1-se">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-carat-1-s"><span class="ui-icon ui-icon-carat-1-s">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-carat-1-sw"><span class="ui-icon ui-icon-carat-1-sw">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-carat-1-w"><span class="ui-icon ui-icon-carat-1-w">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-carat-1-nw"><span class="ui-icon ui-icon-carat-1-nw">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-carat-2-n-s"><span class="ui-icon ui-icon-carat-2-n-s">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-carat-2-e-w"><span class="ui-icon ui-icon-carat-2-e-w">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-triangle-1-n"><span class="ui-icon ui-icon-triangle-1-n">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-triangle-1-ne"><span class="ui-icon ui-icon-triangle-1-ne">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-triangle-1-e"><span class="ui-icon ui-icon-triangle-1-e">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-triangle-1-se"><span class="ui-icon ui-icon-triangle-1-se">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-triangle-1-s"><span class="ui-icon ui-icon-triangle-1-s">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-triangle-1-sw"><span class="ui-icon ui-icon-triangle-1-sw">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-triangle-1-w"><span class="ui-icon ui-icon-triangle-1-w">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-triangle-1-nw"><span class="ui-icon ui-icon-triangle-1-nw">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-triangle-2-n-s"><span class="ui-icon ui-icon-triangle-2-n-s">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-triangle-2-e-w"><span class="ui-icon ui-icon-triangle-2-e-w">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-1-n"><span class="ui-icon ui-icon-arrow-1-n">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-1-ne"><span class="ui-icon ui-icon-arrow-1-ne">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-1-e"><span class="ui-icon ui-icon-arrow-1-e">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-1-se"><span class="ui-icon ui-icon-arrow-1-se">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-1-s"><span class="ui-icon ui-icon-arrow-1-s">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-1-sw"><span class="ui-icon ui-icon-arrow-1-sw">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-1-w"><span class="ui-icon ui-icon-arrow-1-w">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-1-nw"><span class="ui-icon ui-icon-arrow-1-nw">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-2-n-s"><span class="ui-icon ui-icon-arrow-2-n-s">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-2-ne-sw"><span class="ui-icon ui-icon-arrow-2-ne-sw">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-2-e-w"><span class="ui-icon ui-icon-arrow-2-e-w">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-2-se-nw"><span class="ui-icon ui-icon-arrow-2-se-nw">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowstop-1-n"><span class="ui-icon ui-icon-arrowstop-1-n">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowstop-1-e"><span class="ui-icon ui-icon-arrowstop-1-e">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowstop-1-s"><span class="ui-icon ui-icon-arrowstop-1-s">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowstop-1-w"><span class="ui-icon ui-icon-arrowstop-1-w">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthick-1-n"><span class="ui-icon ui-icon-arrowthick-1-n">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthick-1-ne"><span class="ui-icon ui-icon-arrowthick-1-ne">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthick-1-e"><span class="ui-icon ui-icon-arrowthick-1-e">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthick-1-se"><span class="ui-icon ui-icon-arrowthick-1-se">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthick-1-s"><span class="ui-icon ui-icon-arrowthick-1-s">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthick-1-sw"><span class="ui-icon ui-icon-arrowthick-1-sw">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthick-1-w"><span class="ui-icon ui-icon-arrowthick-1-w">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthick-1-nw"><span class="ui-icon ui-icon-arrowthick-1-nw">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthick-2-n-s"><span class="ui-icon ui-icon-arrowthick-2-n-s">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthick-2-ne-sw"><span class="ui-icon ui-icon-arrowthick-2-ne-sw">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthick-2-e-w"><span class="ui-icon ui-icon-arrowthick-2-e-w">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthick-2-se-nw"><span class="ui-icon ui-icon-arrowthick-2-se-nw">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthickstop-1-n"><span class="ui-icon ui-icon-arrowthickstop-1-n">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthickstop-1-e"><span class="ui-icon ui-icon-arrowthickstop-1-e">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthickstop-1-s"><span class="ui-icon ui-icon-arrowthickstop-1-s">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowthickstop-1-w"><span class="ui-icon ui-icon-arrowthickstop-1-w">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowreturnthick-1-w"><span class="ui-icon ui-icon-arrowreturnthick-1-w">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowreturnthick-1-n"><span class="ui-icon ui-icon-arrowreturnthick-1-n">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowreturnthick-1-e"><span class="ui-icon ui-icon-arrowreturnthick-1-e">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowreturnthick-1-s"><span class="ui-icon ui-icon-arrowreturnthick-1-s">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowreturn-1-w"><span class="ui-icon ui-icon-arrowreturn-1-w">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowreturn-1-n"><span class="ui-icon ui-icon-arrowreturn-1-n">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowreturn-1-e"><span class="ui-icon ui-icon-arrowreturn-1-e">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowreturn-1-s"><span class="ui-icon ui-icon-arrowreturn-1-s">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowrefresh-1-w"><span class="ui-icon ui-icon-arrowrefresh-1-w">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowrefresh-1-n"><span class="ui-icon ui-icon-arrowrefresh-1-n">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowrefresh-1-e"><span class="ui-icon ui-icon-arrowrefresh-1-e">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrowrefresh-1-s"><span class="ui-icon ui-icon-arrowrefresh-1-s">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-4"><span class="ui-icon ui-icon-arrow-4">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-arrow-4-diag"><span class="ui-icon ui-icon-arrow-4-diag">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-extlink"><span class="ui-icon ui-icon-extlink">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-newwin"><span class="ui-icon ui-icon-newwin">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-refresh"><span class="ui-icon ui-icon-refresh">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-shuffle"><span class="ui-icon ui-icon-shuffle">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-transfer-e-w"><span class="ui-icon ui-icon-transfer-e-w">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-transferthick-e-w"><span class="ui-icon ui-icon-transferthick-e-w">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-folder-collapsed"><span class="ui-icon ui-icon-folder-collapsed">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-folder-open"><span class="ui-icon ui-icon-folder-open">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-document"><span class="ui-icon ui-icon-document">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-document-b"><span class="ui-icon ui-icon-document-b">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-note"><span class="ui-icon ui-icon-note">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-mail-closed"><span class="ui-icon ui-icon-mail-closed">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-mail-open"><span class="ui-icon ui-icon-mail-open">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-suitcase"><span class="ui-icon ui-icon-suitcase">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-comment"><span class="ui-icon ui-icon-comment">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-person"><span class="ui-icon ui-icon-person">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-print"><span class="ui-icon ui-icon-print">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-trash"><span class="ui-icon ui-icon-trash">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-locked"><span class="ui-icon ui-icon-locked">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-unlocked"><span class="ui-icon ui-icon-unlocked">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-bookmark"><span class="ui-icon ui-icon-bookmark">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-tag"><span class="ui-icon ui-icon-tag">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-home"><span class="ui-icon ui-icon-home">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-flag"><span class="ui-icon ui-icon-flag">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-calculator"><span class="ui-icon ui-icon-calculator">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-cart"><span class="ui-icon ui-icon-cart">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-pencil"><span class="ui-icon ui-icon-pencil">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-clock"><span class="ui-icon ui-icon-clock">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-disk"><span class="ui-icon ui-icon-disk">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-calendar"><span class="ui-icon ui-icon-calendar">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-zoomin"><span class="ui-icon ui-icon-zoomin">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-zoomout"><span class="ui-icon ui-icon-zoomout">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-search"><span class="ui-icon ui-icon-search">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-wrench"><span class="ui-icon ui-icon-wrench">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-gear"><span class="ui-icon ui-icon-gear">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-heart"><span class="ui-icon ui-icon-heart">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-star"><span class="ui-icon ui-icon-star">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-link"><span class="ui-icon ui-icon-link">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-cancel"><span class="ui-icon ui-icon-cancel">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-plus"><span class="ui-icon ui-icon-plus">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-plusthick"><span class="ui-icon ui-icon-plusthick">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-minus"><span class="ui-icon ui-icon-minus">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-minusthick"><span class="ui-icon ui-icon-minusthick">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-close"><span class="ui-icon ui-icon-close">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-closethick"><span class="ui-icon ui-icon-closethick">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-key"><span class="ui-icon ui-icon-key">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-lightbulb"><span class="ui-icon ui-icon-lightbulb">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-scissors"><span class="ui-icon ui-icon-scissors">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-clipboard"><span class="ui-icon ui-icon-clipboard">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-copy"><span class="ui-icon ui-icon-copy">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-contact"><span class="ui-icon ui-icon-contact">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-image"><span class="ui-icon ui-icon-image">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-video"><span class="ui-icon ui-icon-video">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-script"><span class="ui-icon ui-icon-script">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-alert"><span class="ui-icon ui-icon-alert">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-info"><span class="ui-icon ui-icon-info">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-notice"><span class="ui-icon ui-icon-notice">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-help"><span class="ui-icon ui-icon-help">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-check"><span class="ui-icon ui-icon-check">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-bullet"><span class="ui-icon ui-icon-bullet">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-radio-off"><span class="ui-icon ui-icon-radio-off">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-radio-on"><span class="ui-icon ui-icon-radio-on">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-pin-w"><span class="ui-icon ui-icon-pin-w">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-pin-s"><span class="ui-icon ui-icon-pin-s">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-play"><span class="ui-icon ui-icon-play">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-pause"><span class="ui-icon ui-icon-pause">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-seek-next"><span class="ui-icon ui-icon-seek-next">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-seek-prev"><span class="ui-icon ui-icon-seek-prev">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-seek-end"><span class="ui-icon ui-icon-seek-end">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-seek-first"><span class="ui-icon ui-icon-seek-first">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-stop"><span class="ui-icon ui-icon-stop">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-eject"><span class="ui-icon ui-icon-eject">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-volume-off"><span class="ui-icon ui-icon-volume-off">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-volume-on"><span class="ui-icon ui-icon-volume-on">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-power"><span class="ui-icon ui-icon-power">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-signal-diag"><span class="ui-icon ui-icon-signal-diag">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-signal"><span class="ui-icon ui-icon-signal">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-battery-0"><span class="ui-icon ui-icon-battery-0">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-battery-1"><span class="ui-icon ui-icon-battery-1">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-battery-2"><span class="ui-icon ui-icon-battery-2">span>li>
<li class="ui-state-default ui-corner-all" title=".ui-icon-battery-3"><span class="ui-icon ui-icon-battery-3">span>li>
<li class=
你可能感兴趣的:(javascript日常总结,jquery)