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>
时间: 2024-07-30 21:52:43

jquery属性选择器(同时匹配多个条件)的相关文章

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> &

jQuery属性选择器.attr()和.prop()两种方法

在判断表单单选框是否被选中时,通常会想到使用$('#checkbox').attr('checked')来判断,但在一些情况下,你会发现这种方法并不管用,得到的是undefined. 原来jQuery在1.6版本以后对属性选择器做了一些调整,分为.attr()和.prop()两种方法.为的是区分元素attributes和properties之间模棱两可的东西. 那么它们之间有什么区别呢? 官方的解释是: Attributes vs. Properties The difference betwe

jquery属性选择器

jQuery( "[attribute|='value']" ) 选择指定属性值等于给定字符串或以该字符串为前缀(该字符串后跟一个连字符“-” )的元素. eg: $("div[name|='username']").css("border","1px solid red"); jQuery( "[attribute*='value']" ) 选择指定属性具有包含一个给定的子字符串的元素. eg: $(&q

演示-JQuery属性选择器

1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="

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>

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> &

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> &

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> &

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>