jQuery [attribute!=value]选择器

[attribute!=value]选择器语法

$(“[attribute!='value']”)

[attribute!=value]选择器语法解析

jQuery中的[attribute!=value]选择器,用于选择所有属性值为不等于value的元素,比如class!='example',注意引号的使用。

[attribute!=value]选择器实例代码

如下实例代码,通过[attribute!=value]选择器选择target属性不为"_self"的a元素,即将从当前窗口打开的链接的CSS样式和从新的窗口打开的链接的CSS样式区分开来:

<a href="https://www.x1y1z1.com/python/python_index.html" target="_blank">Python教程</a><br>
<a href="https://www.x1y1z1.com/c/c_index.html" target="_self">C语言教程</a><br>
<button id="test">确定</button>

<script>
$("#test").click(function(){
  $("[target='_self']").css("font-size","3em")
})
</script>

免责声明:内容仅供参考,不保证正确性!


全栈前端 / jQuery教程 :






Copyright © 2022-2024 笨鸟工具 x1y1z1.com All Rights Reserved.