• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • [name|='value']

    选择指定属性值等于给定字符串或以该字符串为前缀(该字符串后跟一个连字符“-”)的元素。

    jQuery("[attribute|='value']")

    attribute:一个属性名.

    value:一个属性值,引号是可选的。可以是一个不带引号的一个单词或带一个引号的字符串。

    这个选择器是引入CSS规范来处理语言属性。

    例子

    查找hreflang属性值是英语的所有链接。

    <!DOCTYPE html>
    <html>
    <head>
      <style>
    a { display: inline-block; }
      </style>
      <script src="https://www.lanmper.cn/static/js/jquery-3.5.0.js"></script>
    </head>
    <body>
     
      <a href="example" hreflang="en">Some text</a> 
     
      <a href="example" hreflang="en-UK">Some other text</a>
     
      <a href="example" hreflang="english">will not be outlined</a>
     
    <script>
    $('a[hreflang|="en"]').css('border','3px dotted green');
    </script>
     
    </body>
    </html>
    

    下篇:[name*='value']