Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
140
rated 0 times [  145] [ 5]  / answers: 1 / hits: 15241  / 13 Years ago, mon, june 27, 2011, 12:00:00

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?


More From » jquery

 Answers
6
$(function(){
$('#l, #a').css('color','red');
});


Fiddle: http://jsfiddle.net/maniator/2Xuat/


[#91476] Saturday, June 25, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tomas

Total Points: 165
Total Questions: 111
Total Answers: 103

Location: Maldives
Member since Tue, Dec 21, 2021
2 Years ago
;