Roger
Roger

Reputation:

Text Shadow with jquery

I wish to change the text-shadow attribute of elements with javascript. As far as I know jquery css does not work with text-shadow.

Does anyone have any suggestions for dynamically changing text-shadow.

Thanks!

Upvotes: 2

Views: 17078

Answers (4)

Manuel Hilhorst
Manuel Hilhorst

Reputation: 1

You can also place it inside an object.

({"text-shadow" : "#6374AB 20px 12px 2px"})

Upvotes: 0

mintedsky
mintedsky

Reputation: 1103

$("#text").hover(function() { 
    $(this).animate({textShadow: "#aaa 6px 6px 6px"});
}, function() { 
    $(this).animate({textShadow: "#ccc 3px 3px 3px"});
});

This and more at Alex Peattie's website: http://alexpeattie.com/projects/animate-textshadow/

Upvotes: 0

BraedenP
BraedenP

Reputation: 7215

Works for me (Chrome and FF, not IE).

Try using camelCase. When working with CSS properties in JavaScript, you have to remove the hyphen (for example, "background-image" would become "backgroundImage") and then set the properties.

So your code should read:

$('#bla').css('textShadow','#6374AB 20px -12px 2px');

Upvotes: 11

varl
varl

Reputation: 311

There is always this this little script.

But I don't understand why this wouldn't work:

$('#bla').css('text-shadow','#6374AB 20px -12px 2px');

Edit: Well, I tried it, and indeed jQuery was not impressed with my attempts. But I did find another script.

Cheers!

Upvotes: 0

Related Questions