zoukankan      html  css  js  c++  java
  • jquery属性选择器(同时匹配多个条件)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
      <title>属性选择器</title>
      <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
      <style type="text/css">
      .yang{ border-collapse: collapse; width:500px;height:30px;border:1px solid red;"}
      </style>
      <script  type="text/javascript" src="jquery-1.7.1.min.js"></script>
      <script type="text/javascript">
      /*
        [attribute]  :匹配具有指定属性的元素
        [attribute=value]  :匹配属性为指定值的元素
        [attribute!=value]  :匹配属性值不等于指定值的元素
        [attribute^=value]  :匹配属性值以指定值开始的元素
        [attribute$=value]  :匹配属性值以指定值结束的元素
        [attribute*=value]  :匹配属性值中包含指定值的元素
        [selector1][selector2][selectorN] :同时指定多个匹配条件
      */
            window.onload=function(){
            $('#btnOk').click(function(){
            //匹配具有color属性的font并把内容改为jquery
            //$('font[color]').html('jquery');
    
            //:匹配属性为指定值的元素
            //$("font[color='#667788']").html('颜色');
               
             //  匹配属性不为指定值的元素
            //$("font[color!='#667788']").html('颜色');
    
            //匹配属性值以指定值开始的元素
            //$("font[color^='#667788']").html('我的');
    
             同时指定多个匹配条件
            $('font[size][color]').html('YUYJN');
    
                });
            };
      </script>
     </head>
     <body>
        <font size="6">字体1</font>
        <hr />
        <font color="#336699">字体2</font>
        <hr />
        <font color="#667788">字体3</font>
        <hr />
        <font color="#338899">字体4</font>
        <hr />
        <font size='6' color="#FFAA99">字体5</font>
        <hr />
      <hr/>
      <input type="button" id='btnOk' value='确定'  />
     </body>
    </html>
  • 相关阅读:
    C# Lambda表达式
    C# LINQ用法
    C# XML介绍及基本操作
    C# 装箱和拆箱
    C# 堆与栈
    C#中ref和out的区别
    C#中16进制string字符串的转16byte互转
    C#中把一个Struct结构转换成Byte[]的方法
    SqlServer中查询操作记录的方法
    asp.net中后台获取Post参数(Json)最简单的一种方法。
  • 原文地址:https://www.cnblogs.com/yangzailu/p/5845616.html
Copyright © 2011-2022 走看看