jQuery [attribute=value]选择器
[attribute=value]选择器语法
$(“[attribute='value']”)
提示:value的值一般是字符串的形式,注意引号的使用!
[attribute=value]选择器语法解析
jQuery中的[attribute=value]选择器,用于匹配选择所有元素属性attribute的属性值为value的HTML元素,比如id='benniao'等等。
[attribute=value]选择器实例代码
下方实例,通过[attribute=value]选择器选择所有href属性为https://www.x1y1z1.com/jquery/jquery_index.html的元素:
<a href="https://www.x1y1z1.com/jquery/jquery_index.html" target="_blank">jQuery教程</a><br>
<a href="https://www.x1y1z1.com/jquery/elementselector.html" target="_blank">id选择器</a><br>
<button id="test">确定</button>
<script>
$("#test").click(function(){
$("[href='https://www.x1y1z1.com/jquery/jquery_index.html']").css("font-size","3em")
})
</script>
免责声明:内容仅供参考,不保证正确性!