简体   繁体   English

Internet Explorer上的jQuery悬停效果问题

[英]jQuery hover effect issue on internet explorer

I basically wrote my own jQuery hover effect plugin that works in all browsers except in IE(9,8,7).... 我基本上写了我自己的jQuery hover effect插件,该插件可在除IE(9,8,7)之外的所有浏览器中使用。

Here is the link : http://www.fiver.org/web/testing This is the code: 这是链接: http : //www.fiver.org/web/testing这是代码:

function go()
{

  hoverEffect = document.getElementsByName("hoverEffect");
  for (i=0; i<hoverEffect.length; i++)
  {
    $(hoverEffect[i]).bind('mouseenter', bMouseOver);
    $(hoverEffect[i]).bind('mouseleave', bMouseOut);
  }

  function bMouseOver(e)
  { 
    $(this).find(".fadebox")
      .animate({opacity: 1},
      300);                                         
  }


  function bMouseOut(e)
  { 
    $(this).find(".fadebox")
      .animate({opacity: 0},
      {duration: 'slow'});

  }


}

$(document).ready(function(){
    go();
});

it's a basic hover effect that's cracking my head! 这是一个基本的悬停效果,真是令人头疼! do you have any ideas??? 你有什么想法???

Best, 最好,

IE-s getElementsByName has some problems, i wouldn't rely on it. IE的getElementsByName有一些问题,我不会依赖它。

Try to give those elements a class, instead of name, and select them with jQuery. 尝试给这些元素一个类而不是名称,并使用jQuery选择它们。

Example

HTML: HTML:

<div class="hoverEffect">one</div>    
<div class="hoverEffect">two</div>
<div class="hoverEffect">three</div>

Selecting them with JQuery, and assigning events: 使用JQuery选择它们,并分配事件:

$(".hoverEffect").bind('mouseenter', bMouseOver);
$(".hoverEffect").bind('mouseleave', bMouseOut);

This will also get rid of an extra iterating through the DOM and the using of needless arrays (hoverEffect[]) 这也将避免通过DOM进行额外的迭代以及使用不必要的数组(hoverEffect [])

Try using opacity:.00 instead of opacity:0 尝试使用opacity:.00而不是opacity:0

jQuery opacity animations work better when using .00 as zero opacity instead of 0. I can't really explain and find any documentation why this is, but it had fixed my problems in the past. 当使用.00作为零不透明度而不是0时,jQuery不透明度动画效果更好。我无法真正解释和找到任何说明为什么这样做的文档,但是过去已经解决了我的问题。

Also a little more information about what doesn't work in this script would help :) 另外,有关此脚本中无效内容的更多信息也会有所帮助:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM