jQuery多属性选择器问题 [英] jquery multiple attribute selector problem

查看:62
本文介绍了jQuery多属性选择器问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,为什么这个简单的代码不起作用?

I've a little question, why this simple code does not work?

html:

<input type="text" name="a" id="a">
<input type="text" name="ab" id="ab">
<input type="text" name="b" id="b">
<input type="text" name="c" id="c">
<input type="text" name="d" id="d">

js:

$("[name^='a'][name='c']").css("background-color", "red");

提前,谢谢.

推荐答案

您需要在选择器中添加逗号:

You need to add comma to your selector:

$("[name^='a'],[name='c']").css("background-color", "red");

这篇关于jQuery多属性选择器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆