有示例:http : //www.jquery4u.com/jquery-functions/setinterval-example/#.UHW6_IYY18E 将鼠标悬停在 RSS feedburner 图像上 - 它会摇晃。
就我而言,我有 2 个图像:non-hover.png、hover.png。
当 a:link - 它显示为背景 non-hover.png,当你悬停时它显示 hover.png 并以 3 秒的间隔切换到 non-hover.png(当光标仍在此链接上时),就像无限循环,您悬停,它会以 3 秒的间隔将 non-hover.png 切换为 hover.png。
当光标在锚点上方时,我希望 jquery 每三秒在两个图像之间切换一次。
解决方案。
    $(document).ready(function() {
      function pizdec() {
        setTimeout(function(){ $('.istina').css('background-image','url("<?php print $base_path . $directory ?>/img/istina.png")'); }, 500);
        $('.istina').css('background-image', 'url("<?php print $base_path . $directory ?>/img/istina-hover.png")');
      }
  var IntervalID;
  $('.istina').hover(function() {
    pizdec();
    IntervalID = setInterval(pizdec, 1000)
  }, function() {
      clearInterval(IntervalID);
    }
  )
});