<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. TCPDump:捕获并记录特定协议 / 端口

    Q. 如何使用 Linux / UNIX 平台下的 TCPDump 工具捕获特定协议或端口比如 80 (http)?如何使用 TCPDump 将流记录下来,然后(根据记录)查找到问题所在?       ...

  2. 13-(1-4)进程管道关于popen(-r-w)及pipe的程序使用实例

    #include<unistd.h> #include<stdlib.h> #include<stdio.h> #include<string.h> # ...

  3. Android Branch and master source code merge(patch)

    Environment : Android 4.4.2 merge with Android 4.4.3(with other vendors source code) 1.确定你要merge 到 其 ...

  4. HDU 4882 ZCC Loves Codefires(贪心)

     ZCC Loves Codefires Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  5. password学3——Java BASE64加密解密

    Base64是网络上最常见的用于传输8Bit字节代码的编码方式之中的一个,大家能够查看RFC2045-RFC2049.上面有MIME的具体规范.Base64编码可用于在HTTP环境下传递较长的标识信息 ...

  6. Selenium 出现: Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ElementTraversal

    webDriver 运行的时候出现: Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ElementTraversal 解决办法: 只 ...

  7. Boost::asio io_service 实现分析

    io_service的作用 io_servie 实现了一个任务队列,这里的任务就是void(void)的函数.Io_servie最常用的两个接口是post和run,post向任务队列中投递任务,run ...

  8. SRM 582 Div II Level Two SpaceWarDiv2

    题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12556 #include <iostream> # ...

  9. Oracle判断指定列是否全部为数字

    select nvl2(translate(name,'\1234567890 ', '\'),'is   characters ','is   number ') from customer_inf ...

  10. Servlet的学习(一)

    初识Servlet Servlet是一门专门用于开发动态web资源的技术,Sun公司在其API中提供了一个Servlet接口(当然,我们不会去直接实现这个接口,而是去继承其实现类会更好),因此,狭义的 ...