Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery hover effect

How can I get same effect like this

http://bavotasan.com/demos/fadehover/

But only for anchor tags not for images, let say I have anchor background blue and I want it to change to red but with this effect, how can I do that? thank you

like image 212
Gandalf StormCrow Avatar asked Apr 26 '26 08:04

Gandalf StormCrow


1 Answers

Use hover and animate. Note that this requires the jQuery color animations plugin.

<html>
<head>
  <title>color change</title>
  <script type="text/javascript" src="http://code.jquery.com/jquery.js"></script>
  <script src="http://plugins.jquery.com/files/jquery.color.js.txt" type="text/javascript" charset="utf-8"></script>
  <script type="text/javascript" charset="utf-8">
    $(function() {
      $('a').hover(function() {
        $(this).animate({
          color: "#f00"
        }, "fast")
      }, function() {
        $(this).animate({
          color: "#00f"
        }, "fast")
      });
    });
  </script>
  <style>
    a { color: #00f; }
  </style>
</head>
<body>
  <a href="#">This changes color on hover.</a>
</body>
</html>

In the example of changing color on an a element there is no reason to use the crossfade effect used in the link you provide.

like image 190
Jimmy Avatar answered Apr 27 '26 23:04

Jimmy



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!