Fading colors with jquery?

前端 未结 3 1227
余生分开走
余生分开走 2021-01-28 10:08

I have a regular color change using jquery, but I\'d like to have it so it has a smooth color change. At the moment, the code changes the color of a link on hover and then remov

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-28 10:39

    You'd use .animate(), like this:

    $(document).ready(function() {
      $("#link1,#link2,#link3").hover(function() {
        $(this).stop().animate({ color: "#990000" });
      },function(){
        $(this).stop().animate({ color: "#FFFFFF" });
      }); 
    });
    

    Note though, you need either the color plugin, or jQuery UI included for color animations to work.

提交回复
热议问题