<!DOCTYPE HTML>
<html>
<head>
<title> 使用jQuery基本过滤选择器 </title>
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
</head>
<body>
<div>
<h1>基本过滤选择器</h1>
<ul>
<li class="DefClass">Item 0</li>
<li class="DefClass">Item 1</li>
<li class="NotClass">Item 2</li>
<li class="DefClass">Item 3</li>
</ul>
<span id="spanMove">Span Move</span>
</div>
</body>
</html>
body{
font-size:12px;
text-align:center
}
div{
width:241px;
height:83px;
border:solid 1px #ccc
}
h1 {
font-size:13px
}
ul {
list-style-type:none;padding:0px
}
.DefClass,.NotClass{
width:60px;
height:23px;
line-height:23px;
float:left;
border-top:solid 1px #eee;
border-bottom:solid 1px #eee
}
.GetFocus{
width:58px;
border-bottom:solid 1px #666;
background-color:#eee
}
#spanMove{
width:238px;
height:23px;
line-height:23px
}
$(function (){//jQuery代码

1.  ul中的第一个li元素添加样式;
$("ul li:first").addClass("GetFocus");
$("ul li").first().addClass("GetFocus"); 2. ul中的最后一个li元素添加样式;
$("ul li:last").addClass("GetFocus");
$("ul li").last().addClass("GetFocus"); 3. ul中的非class=“NotClass” li元素添加样式;
$("ul li:not(.NotClass)").addClass("GetFocus"); 4. ul中的 li索引值为偶数的元素添加样式;从0开始计数
$("ul li:even").addClass("GetFocus"); 5. ul中的 li索引值为奇数的元素添加样式;从0开始计数
$("ul li:odd").addClass("GetFocus"); 6.增加一个给定索引值的元素类别,从0开始计数
$("li:eq(1)").addClass("GetFocus"); 7.增加所有大于给定索引值的元素类别,从0开始计数
$("li:gt(1)").addClass("GetFocus"); 8.增加所有小于给定索引值的元素类别,从0开始计数
$("li:lt(4)").addClass("GetFocus"); 9.//增加标题类元素类别
$("div h1").css("width","238");
$(":header").addClass("GetFocus");
})

1.  

2.

3.

4.

5.

6.

7.

8.

9.

jQuery 简单过滤选择器的更多相关文章

  1. jQuery简单过滤选择器

    <html xmlns="http://www.w3.org/1999/xhtml"> <head>     <!--jQuery选择器详解 根据所获 ...

  2. jQuery基本过滤选择器

    jQuery基本过滤选择器: <h1>this is h1</h1> <div id="p1"> <h2>this is h2< ...

  3. Jquery的过滤选择器分为哪几种?

    Jquery的过滤选择器分为哪几种? 转载▼ 标签: jquery 过滤选择器 分类 分类: JQuery 所有的过滤选择器分为哪几种: 一.基本过滤选择器(重点掌握下列八个) :first 选取第一 ...

  4. 第一百六十五节,jQuery,过滤选择器

    jQuery,过滤选择器 学习要点: 1.基本过滤器 2.内容过滤器 3.可见性过滤器 4.子元素过滤器 5.其他方法 过滤选择器简称:过滤器.它其实也是一种选择器,而这种选择器类似与 CSS3 (h ...

  5. jquery :checked(过滤选择器) 和 空格:checked(后代选择器)

    jquery 过滤选择器 和 后代选择器 <%@ page language="java" contentType="text/html; charset=UTF- ...

  6. JQuery 可见性过滤选择器

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  7. JQuery 内容过滤选择器

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  8. jQuery内容过滤选择器与子元素过滤选择器用法实例分析

    jQuery选择器内容过滤 一.:contains(text) 选择器::contains(text)描述:匹配包含给定文本的元素返回值:元素集合 示例: ? 1 2 $("div.mini ...

  9. jquery :checked(过滤选择器) 和 空格:checked(后代选择器)【转】

    jquery 过滤选择器 和 后代选择器 <%@ page language="java" contentType="text/html; charset=UTF- ...

随机推荐

  1. [CareerCup] 18.13 Largest Rectangle of Letters

    18.13 Given a list of millions of words, design an algorithm to create the largest possible rectangl ...

  2. IE 9 以下兼容HTML5

    <head> <meta name="viewport" content="width=device-width,initial-scale=1.0&q ...

  3. 详解NTFS文件系统

    一.分析NTFS文件系统的结构 当用户将硬盘的一个分区格式化为NTFS分区时,就建立了一个NTFS文件系统.NTFS文件系统同FAT32文件系统一样,也是用“簇”为存储单位,一个文件总是占用一个或多个 ...

  4. gcc和g++

    一.GCC GNU编译器套件(GNU Compiler Collection)包括C.C++.Objective-C.Fortran.Java.Ada和Go语言的前端,也包括了这些语言的库(如libs ...

  5. 【iCore3 双核心板】例程十二:通用定时器实验——定时点亮LED

    实验指导书及代码包下载: http://pan.baidu.com/s/1kTWAAJ9 iCore3 购买链接: https://item.taobao.com/item.htm?id=524229 ...

  6. JavaScript显示当前时间的代码

    方法一: <script type="text/javascript"> function startTime() { //获取当前系统日期 var today=new ...

  7. Customizing the Editor

    Use the General, Text Editor, Options Dialog Box to customize the appearance and functionality of th ...

  8. 15.2 THE USE OF A LARGE REGISTER FILE

    COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION

  9. UIView添加手势

    _shareImage.userInteractionEnabled=YES; UITapGestureRecognizer *imagegesture=[[UITapGestureRecognize ...

  10. ssm框架web.xml中filter配置问题

    <?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://w ...