Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set link color using jquery.css()

Tags:

jquery

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.

like image 674
Joper Avatar asked Mar 11 '26 11:03

Joper


2 Answers

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.

like image 97
Aron Rotteveel Avatar answered Mar 14 '26 03:03

Aron Rotteveel


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;
}
like image 21
tildy Avatar answered Mar 14 '26 03:03

tildy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!