Reputation: 85545
I have styled my css like this
.mycss{border: 2px solid; background: url("") no-repeat;}
how could I add #f00
right after solid and right after no-repeat with a space with jquery?
Edit What if I would like to edit my css with js?
Upvotes: 0
Views: 60
Reputation: 11371
As others mentioned, css is the way to go. But, if you still want to use jQuery, here's a way you could do this.
Add a class with the styles you want to add when hovering.
.onHover {
border-color: #f00;
background-color : #f00
}
Then you could use the hover
event of jQuery and toggle
the class whenever hovering.
$(".mycss").hover(function () {
$(this).toggleClass("onHover");
});
Demo : http://jsfiddle.net/hungerpain/gU7Zp/
Upvotes: 0
Reputation: 18194
Use specific CSS properties for color:
background-color: #f00
That will not override background-image
or background-position
. For border there is border-color
property.
Upvotes: 0
Reputation: 706
You can simply use this:
.mycss:hover{border: #f00; background-color: #f00;}
and it will do what you want you can add it rightin your css or your html page as a style
tag there is no need to use js or jq for this, and it will add them to this css because you are adding something not editting :D
Upvotes: 1