admin管理员组文章数量:1201581
Here is my html
:
<div id="l">l</div>
<div id="a">a</div>
<div id="i">i</div>
How to change the color of only the l
and a
attributed elements? I searched for a selector with OR, something like this:
$(function(){
$('div[id=l,a]').css('color','red');
});
It's not working, is there something like that in jQuery?
EDIT Thank you guys it's working now:
$('[id=l], [id=a]').css('color', 'red');
But what if I want to search for those IDs inside a <div>
like $('[id=l], [id=a]','div')
. This doesn't work, how should I do it?
Here is my html
:
<div id="l">l</div>
<div id="a">a</div>
<div id="i">i</div>
How to change the color of only the l
and a
attributed elements? I searched for a selector with OR, something like this:
$(function(){
$('div[id=l,a]').css('color','red');
});
It's not working, is there something like that in jQuery?
EDIT Thank you guys it's working now:
$('[id=l], [id=a]').css('color', 'red');
But what if I want to search for those IDs inside a <div>
like $('[id=l], [id=a]','div')
. This doesn't work, how should I do it?
1 Answer
Reset to default 23$(function(){
$('#l, #a').css('color','red');
});
Fiddle: http://jsfiddle.net/maniator/2Xuat/
本文标签: javascriptjQuery Attribute Selectors OR OperationStack Overflow
版权声明:本文标题:javascript - jQuery Attribute Selectors OR Operation - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738569666a2100518.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论