带有背景图像的.hover上的无限循环


  <script type="text/javascript">
    $(document).ready(function() {
      $('.istina').hover(function() {
        animate_loop = function() {
          $(this).css('backgroundImage', 'url(<?php print $base_path . $directory ?>/img/istina-hover.png)').animate({backgroundImage: 'url(/sites/all/themes/ruh/img/istina.png)'}, 500, function() { animate_loop(); } );
      }, function() {
          $(this).css('backgroundImage', 'url(<?php print $base_path . $directory ?>/img/istina.png)');
        }
        }
      )
    });

我有一个与类的链接<a class="istina">some text</a>我想在悬停时更改它的背景图像,在悬停时我想在 istina.png 和 istina-hover 之间切换.png

谢谢!

你不需要任何javascript来做到这一点,它可以是CSS驱动的...

.html:

<a class="istina">some text</a>

.css

#istina {  
background-image : url(istina.png); 
}
#istina :hover { 
background-image : url(istina-hover.png); 
}

最新更新