jQuery: The Write Less, Do More JavaScript Library

Talk:CSS/css

From jQuery JavaScript Library

Jump to: navigation, search

Matt Helm: (10/24/2007)
I have a question. Why can't we just use the css names. Example: instead of using your style "backgroundColor", why not just use "background-color", as in css? Why can't we change that? Later

davidserduke: (10/27/2007)
The answer is: You can.

Look again at the examples and you'll see it works both ways as long as you put the property in quotes like:

.css("background-color", "yellow")

.css("backgroundColor", "yellow")

But you can also use the latter method without quotes if you are using an object literal like:

.css({ backgroundColor: "yellow"})

.css({ "background-color": "yellow"})

Yasmary Mora: (12/18/2007)
Using "blue" or "red" or "black" throws an error in Internet Explorer 7. Use hex values.

modifying css sub-elements

If i have a class and i want to modify the anchor tag CSS values of it - is that possible?

Here's what i'm trying

css:

.my_element { font-size: 10px; }

jquery:

$("a.my_element:link").css('color','red');

i've tried a few methods and no joy. $(".my_element a:link").css('color','red');

Guessing i'm doing something wrong.