Joper
Joper

Reputation: 8209

How to set link color using jquery.css()

Is there any way to set a href link color using the jquery css properties ?

Basically i need to style simple model http://www.ericmmartin.com/projects/simplemodal_v12/ there is containerCss options where i need to pass that style:

New in 1.2, you have the option to use external CSS or to pass in CSS attributes for the modal overlay, container, and data elements as options. The options are: overlayCss, containerCss and dataCss and take a key/value object of properties. See the jQuery CSS Docs for details.

Upvotes: 2

Views: 20159

Answers (3)

Aron Rotteveel
Aron Rotteveel

Reputation: 83163

You can just use the CSS definition for it:

$('a').css({
    color: '#ff0000'
});

Or, alternatively, using a shorter syntax:

$('a').css('color', '#ff0000');

EDIT: since you are using Simplemodal: you are only able to style the overlay, container and data wrapper elements in your modal using the syntax described on this page. If you want to style anything else, simply use CSS or create a jQuery selector based on the DOM node you want to style.

Upvotes: 10

tildy
tildy

Reputation: 999

Easiest way is

$('a').css('color','red');

But I think the best way if we creates a class for them , because it's possible, that he/she need to modify other parameters too. In this case the CSS things will be in the CSS ( and the color is that) , and Jquery using only a class for them .

So :

$('a').addClass('className');

and in the CSS

.className
{
    color:red;
}

Upvotes: 2

ChristopheCVB
ChristopheCVB

Reputation: 7315

Why not using CSS for that ?

a{
    color : red;
}
a:link{
    color : red;
}
a:visited{
    color : red;
}
a:hover{
    color : red;
}

Upvotes: 1

Related Questions