<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--jQuery选择器详解
根据所获取页面中元素的不同,可以将jQuery选择器分为:基本选择器、层次选择器、过滤选择器、表单选择器四大类。其中,在过滤选择器中有可以分为:简单过滤选择器、内容过滤选择器、可见性过滤选择器、属性过滤选择器、子元素过滤选择器、表单对象属性过滤选择器6种

1.简单过滤选择器:根据某类过滤规则进行元素的匹配,书写时都以冒号(:)开头;简单过滤选择器是过滤选择器中使用最广泛的一种

-->
    <title>使用jQuery基本过滤选择器</title>
    <!--使用jQuery基本过滤选择器选择元素:在页面中,设置一个<h1>标记用户显示主题,创建<ul>标记并在其中放置四个<li>,再创建一个<span>标记,用于执行动画效果。通过简单过滤选择器获取元素,将选中的元素改变其类名称,从而突出其被选中的状态-->
    <script src="jquery-1.9.1.js" type="text/javascript"></script>
    <style type="text/css">
    body{font-size:12px;text-align:center;}
    div{width:240px;height:83px;border:solid 1px #eee}
    he{font-size:13px;}
    ul{list-style-type:none;padding:0px}
    .DefClass,.NotClass{height:23px;width:60px;line-height:23px;float:left;border-top:solid 1px #eee;border-bottom:solid 1px #eee}
    .GetFocus{width:58px;border:solid 1px #666;background-color:#eee}
    #spnMove{width:234px;height:23px;line-height:23px;}
    </style>

<script type="text/javascript">
        $(function () {  //增加第一个元素的类别
            $('li:first').addClass('GetFocus');
        })
        $(function () {  //增加最后一个元素的类别
            $('li:last').addClass('GetFocus');
        })
        $(function () {  //增加去除所有与给定选择器匹配的元素类别
            $('li:not(.NotClass)').addClass('GetFocus');
        })
        $(function () {  //增加所有索引值为偶数的元素类别,从0开始计数
            $('li:even').addClass('GetFocus');
        })
        $(function () {  //增加所有索引值为奇数的元素类别,从0开始计数
            $('li:odd').addClass('GetFocus');
        })
        $(function () {  //增加一个给定索引值的元素类别,从0开始计数
            $('li:eq(1)').addClass('GetFocus');
        })
        $(function () {  //增加所有大于给定索引值的元素类别,从0开始计数
            $('li:gt(1)').addClass('GetFocus');
        })
        $(function () {  //增加所有小于给定索引值的元素类别,从0开始计数
            $('li:lt(4)').addClass('GetFocus');
        })
        $(function () {  //增加标题类元素类别
            $('div h1').css('width', '238');
            $(':header').addClass('GetFocus');
        })
        $(function () {
            animateIt();  //增加动画效果元素类别
            $('#spnMove:animated').addClass('GetFocus');
        })
        function animateIt() {  //动画效果
            $('#spnMove').slideToggle('slow', animateIt);
                }
         
    </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="spnMove">Span Move</span>
</div>
</body>
</html>

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

  1. jQuery 简单过滤选择器

    <!DOCTYPE HTML> <html> <head> <title> 使用jQuery基本过滤选择器 </title> <scr ...

  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. 使用tmux [FreeBSDChina Wiki]

    使用tmux [FreeBSDChina Wiki] 使用tmux tmux是一个优秀的终端复用软件,类似GNU Screen,但来自于OpenBSD,采用BSD授权.使用它最直观的好处就是,通过一个 ...

  2. lua中打印所以类型功能实现table嵌套table

    lua中打印所以类型功能实现 本人測试 number.string.bool.nil.table嵌套table.userdata没问题 共享一下有什么问题请拍砖 代码例如以下 cclog = func ...

  3. 操作系统栈溢出检測之ucosII篇

    操作系统栈溢出检測之uc/osII篇 Author               :       David Lin (林鹏) E-mail               :       linpeng1 ...

  4. 网页调试技巧:抓取马上跳转的页面POST信息或者页面内容

    http://www.qs5.org/Post/625.html 网页调试技巧:抓取马上跳转的页面POST信息或者页面内容 2016/02/02 | 心得分享 | 0 Replies 有时候调试网页或 ...

  5. 重操JS旧业第六弹:基本类型包装

    在前面已经知道js中的类型有boolean,string,number,undefined,function,object,其中boolean,number,string为值类型.所谓的基本类型包装, ...

  6. oracle for update和for update nowait(for update wait)的区别

    1.for update 和 for update nowait 的区别: 1.oracle 中执行select 操作读取数据不会有任何限制,当另外一个进程在修改表中的数据,但是并没有commit,所 ...

  7. Enterprise Solution 企业管理软件开发框架

    Enterprise Solution 开源项目资源汇总 Visual Studio Online 源代码托管 企业管理软件开发框架 Enterprise Solution 是一套管理软件开发框架,在 ...

  8. TPanel的默认颜色存储在dfm中,读取后在Paint函数中设置刷子的颜色,然后填充整个背景

    声明如下: TCustomPanel = class(TCustomControl) private FFullRepaint: Boolean; FParentBackgroundSet: Bool ...

  9. Android Sip学习(三)Android Voip实现

    Android Sip学习(三)Android Voip实现   Android Sip学习(准备知识)SIP 协议完整的呼叫流程 Android Sip学习(一)Android 2.3 APIs S ...

  10. jsp:setProperty

    类声明: package test; public class Student {     private int age; public int getAge() {         return ...