-1

EDIT: Answered in comments - how do I vote for an answer in the comments?? Thanks!

I've been trying to implement this to no avail - I have no idea what's wrong - it worked perfectly in jsfiddle but not in my actual html code...I think it's something to do with how I implemented it. I'm sorry if this is a little elementary, but I'm quite new to jQuery. Here's the HTML code (including the jQuery code snippet):

<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="s3Slider.js"></script>

</head>
<body>
<script>
$(document).ready(function(){

$('a').mouseenter(function(){
    $(this).animate({
        color: '#ff0000'
    }, 1000);
}).mouseout(function(){
    $(this).animate({
        color: '#000000'
    }, 1000);
});

});
</script>

<a href = "http://google.com" class = "homeLink">Google</a>

</body>
</html>

Greatly appreciate any feedback, comments and advice! Baggio

9

3 Answers 3

2

Include the color animation JQuery UI in your code and try the same...

it will work

<script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>

Fiddle : http://jsfiddle.net/RYh7U/63/

Reference : http://jqueryui.com/animate/

Sign up to request clarification or add additional context in comments.

1 Comment

Yeah - that's the answer I was looking for, didn't know I needed a separate library to enable UI effects...thanks!
1

You need jQuery Color plugin to animate colors - grab a copy here. Remember to include it after main jQuery lib.

Or maybe just animate opacity instead of color if you want it to appear and disappear completely:

$('a').mouseenter(function(){
    $(this).animate({
        opacity: '1'
    }, 1000);
}).mouseout(function(){
    $(this).animate({
        opacity: '0'
    }, 1000);
});

1 Comment

Thanks for the heads up - again, didn't know I had to ref the UI library (or that one existed for our purposes...) ty!
1

If you want to make the text faded ... use opacity ...

$(document).ready(function(){

   $('a').mouseenter(function() {
     $(this).animate({ opacity : '0.5' }, 1000);
   }).mouseout(function() {
     $(this).animate({ opacity: '1'}, 1000);
   });
});

1 Comment

Opacity is a good option as well, but I don't want just to fade the text, I want to fade it on hover, and back to whatever color it was back before.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.