0
<a class="control selected" id="control1" rel="1" href="#"></a>
<a class="control" id="control2" rel="2" href="#"></a>
<a class="control" id="control3" rel="3" href="#"></a>

I have a jQuery Slider that have thumbnails in a tags like this:

To make it dynamic, I try to select each

$('#control1.control').css("background-color", "red");
$('#control1.control.selected').css("background-color", "green");

The first selector works, but not the second.

Explosion Pills
  • 188,624
  • 52
  • 326
  • 405
Bizboss
  • 7,792
  • 27
  • 109
  • 174

2 Answers2

1

This should work,

$('#control1.control.selected').css("background-color", "green");

Here is explanation on other question, but yes, use single id in a query:

$('#control1')
Community
  • 1
  • 1
Davor Zubak
  • 4,726
  • 13
  • 59
  • 94
0

Both selectors work. See I highlighted the first with red and the second with green colors:

<a class="control" id="control1" rel="1" href="#">1</a>
<a class="control selected" id="control2" rel="2" href="#">2</a>
<a class="control" id="control3" rel="3" href="#">3</a>
<script>
$('#control1.control').css("background-color", "red");
$('#control2.control.selected').css("background-color", "green");
</script>
Geo
  • 12,666
  • 4
  • 40
  • 55