Jquery .hover在IE中发布

时间:2015-09-11 17:23:44

标签: jquery jquery-plugins

我有一些代码可以在相应的链接悬停时为图像着色。更具体地说,在悬停时删除灰度等级。除了IE之外,这似乎无处不在。任何帮助将不胜感激。

谢谢!

$(document).ready(function() {
  $("a.red").hover(
    function() {
      $("img[class*='red']").addClass('grayscale-off');
      $("img[class*='red']").removeClass('grayscale');
    },
    function() {
      $("img[class*='red']").removeClass('grayscale-off');
      $("img[class*='red']").addClass('grayscale');
    });

  $("a.blue").hover(
    function() {
      $("img[class*='blue']").addClass('grayscale-off');
      $("img[class*='blue']").removeClass('grayscale');
    },
    function() {
      $("img[class*='blue']").removeClass('grayscale-off');
      $("img[class*='blue']").addClass('grayscale');
    });

  $("a.one").hover(
    function() {
      $("img[class*='one']").addClass('grayscale-off');
      $("img[class*='one']").removeClass('grayscale');
    },
    function() {
      $("img[class*='one']").removeClass('grayscale-off');
      $("img[class*='one']").addClass('grayscale');
    });
});
img {
  display: block;
  width: 250px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
</script>

<link rel="stylesheet" type="text/css" href="http://cdn.jsdelivr.net/jquery.gray/1.4.5/gray.min.css">

<body>

  <a href="#" class="red">Red Fish</a>
  <br/>

  <a href="#" class="blue">Blue Fish</a>
  <br/>

  <a href="#" class="one">One Fish</a>
  <br/>

  <img class="grayscale red" src="http://needlework.ru/UserFiles/Image/dr_seuss/dr_seuss-fish-design1.jpg" />
  <img class="blue grayscale" src="http://media.liveauctiongroup.net/i/14478/14711122_5.jpg?v=8CF918FFA75BC20" />
  <img class="red grayscale" src="http://media.liveauctiongroup.net/i/14478/14711122_4.jpg?v=8CF918FFA75BC20" />
  <img class="one grayscale" src="http://www.polyvore.com/cgi/img-thing?.out=jpg&size=l&tid=49090099" />
  <img class="blue grayscale" src="http://vignette3.wikia.nocookie.net/seuss/images/1/1d/One-Fish-Two-Fish-Red-Fish-Blue-Fish-picture2.png/revision/latest?cb=20121110004221" />
  <img class="one grayscale" src="http://vignette1.wikia.nocookie.net/seuss/images/8/8a/FISH2.jpg/revision/latest?cb=20140328162337" />

  <script src="http://cdn.jsdelivr.net/jquery.gray/1.4.5/jquery.gray.min.js">
  </script>

</body>

0 个答案:

没有答案