Reputation: 47733
I want to just change one of the elements in a class with jQuery
.myClass
{
background-color:#FFFFFF;
}
I want to programatically change this
Upvotes: 0
Views: 183
Reputation: 19247
jquery doesn't manipulate stylesheets AFAIK. what you can do is change the background-color
of nodes in .myClass:
$('.myClass').css('background-color', '#FF0000');
Upvotes: 1
Reputation: 47
To remove an entire inline style tag:
$('.myClass').removeAttr('style');
http://docs.jquery.com/Attributes/removeAttr#name
Upvotes: 1
Reputation: 125480
If you want to add the myClass
class to a DOM element:
myElement.addClass("myClass");
If you want to remove the myClass
class from a DOM element:
myElement.removeClass("myClass");
For more information, see the jQuery docs on hasClass
, addClass
, removeClass
, and toggleClass
.
Upvotes: 0
Reputation: 41040
http://docs.jquery.com/Attributes/addClass
$("p:last").addClass("myclass");
Upvotes: 1
Reputation: 103135
This changes all .myClass elements. You can change multiple properties of the element.
$(".myClass").css({'background-color':'#BBBBBB'});
Upvotes: 1