Reputation: 16226
I have this CSS rule:
#panelSeparator .active {
background: #fff url(../img/vgrabber.gif) no-repeat center;
opacity: 0.7;
}
I would like to do something like this in JS:
$('#panelSeparator').addClass('active');
How should I change the parameter of addClass in order to make that work?
Thanks,
Dan
Upvotes: 2
Views: 143
Reputation: 1319
If you want to keep the same CSS, then you'll need to do something like $('#panelSeparator div').addClass('active');
in Javascript. Basically, you'd have to select an element inside the #panelSeparator element.
Or you can keep the same Javascript and just change the CSS to #panelSeparator.active
Upvotes: 0
Reputation: 23989
Try removing the space between #panelSeparator .active
so it is #panelSeparator.active
.
Upvotes: 8
Reputation: 10202
your css defines a class which is bound to all children of elements with the id 'panelSeperator'. You should use the jQuery.children() function (http://api.jquery.com/children/);
$('#panelSeparator').children().addClass('active');
Upvotes: 0