Attribute Not Equal Selector [name!="value"]

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

attribute
An attribute name.
attribute:属性名称

value
An attribute value. Can be either an unquoted single word or a quoted string.
value:属性值。引号是可选的。

Description: Select elements that either don't have the specified attribute, or do have the specified attribute but not with a certain value.
This selector is equivalent to :not([attr="value"]).
描述:选择所有没有指定的属性或者指定的属性的值不包含给定的属性值的元素。
该选择器等效于:not([attr="value"])。

Additional Notes:
额外说明:
Because [name!="value"] is a jQuery extension and not part of the CSS specification, queries using [name!="value"] cannot take advantage of the performance boost provided by the native DOM querySelectorAll() method. For better performance in modern browsers, use $("your-pure-css-selector").not('[name="value"]') instead.
因为[name!="value"]是jQuery的一种扩展而不是CSS规范的一部分,因此使用[name!="value"]查找元素将不能使用高效率的原生DOM querySelectorAll()方法。为了更好的效率,应使用$("纯CSS选择器").not('[name="value"]')来代替。

Example:
Finds all inputs that don't have the name 'newsletter' and appends text to the span next to it.
例子:查找所有name属性不为'newsletter'的input元素,然后在其下方的span元素中增加内容。
<!DOCTYPE html>
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
  <div>

    <input type="radio" name="newsletter" value="Hot Fuzz" />
    <span>name is newsletter</span>

  </div>
  <div>
    <input type="radio" value="Cold Fusion" />
    <span>no name</span>

  </div>
  <div>
    <input type="radio" name="accept" value="Evil Plans" />

    <span>name is accept</span>
  </div>
<script>$('input[name!="newsletter"]').next().append('<b>; not newsletter</b>');</script>

</body>
</html>

你可能感兴趣的:(jquery)