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>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值