简体   繁体   English

简单的javascript褪色效果在IE7 / 8中不起作用,在其他浏览器中效果很好

[英]Simple javascript fading effect not working in IE7/8, fine in other browsers

See http://jonesonter.notomato.com.au/ . 参见http://jonesonter.notomato.com.au/

I have a simple fading effect written when you hover on some list elements positioned over a stack of images which are all absolutely positioned on top of each other. 当您将鼠标悬停在位于一堆图像上的某些列表元素上时,我会写出一个简单的淡入淡出效果,这些图像都绝对位于彼此的顶部。

$("#homeNav li").hover(function(){
    //make a variable and assign the hovered id to it
    var elid = $(this).attr('id');
    //hide the image currently there
    $("div#homeImages div").hide();
    //fade in the image with the same id as the selected buttom
    $("div#homeImages div#" + elid + "").fadeIn("slow");

    });

However it won't work in internet explorer. 但是,它在Internet Explorer中不起作用。

I have tried searching around, but can't find a simple fading technique that will let me; 我已经尝试过搜索,但是找不到一种简单的淡入淡出的技术。 have a stack of images position a set of controls (in this case < li> elements) when you hover over a particular control one of the images fades in, the others should all be hidden, the current one should fade out. 将一堆图像放置在一组控件(在本例中为<li>元素)上,当您将鼠标悬停在特定控件上时,其中一个图像会淡入,其他图像都应隐藏,而当前图像应淡出。

IE always seems to have an error and not fade properly. IE似乎总是有错误并且不能正确消失。 Does anyone know where I am going wrong? 有人知道我要去哪里错吗?

A few shots in the dark, I am going home to bed now :) 在黑暗中拍了几枪,我现在要回家睡觉了:)

  • I know from Prototype that the fade effect prefers to have a classless, simple <div> directrly inside the element to be faded. 我从Prototype得知,淡入淡出效果更倾向于在要淡入淡入的元素内部直接具有无类,简单的<div> Can you try adding this to each image? 您可以尝试将其添加到每个图像吗?
  • What happens if you give the images layout (eg using the zoom: 1 CSS property) 如果给图像布局(例如,使用zoom: 1 CSS属性)会发生什么?
  • What happens if you give the images a background color. 如果给图像提供背景色会发生什么。

the following works for me (html changes): 以下对我有用(更改html):

<div id="homeImages">
    <div style="display: none; width:950px; height:500px; background:url('http://jonesonter.notomato.com.au/wp-content/themes/jonesonter/img/home-page/conditioned.jpg');" id="homeConditioned"></div>
    <div style="display: none; width:950px; height:500px; background:url('http://jonesonter.notomato.com.au/wp-content/themes/jonesonter/img/home-page/guided.jpg');" id="homeGuided"></div>
    <div style="display: block; width:950px; height:500px; background:url('http://jonesonter.notomato.com.au/wp-content/themes/jonesonter/img/home-page/informed.jpg');" id="homeInformed"></div>
    <div style="display: none; width:950px; height:500px; background:url('http://jonesonter.notomato.com.au/wp-content/themes/jonesonter/img/home-page/shaped.jpg');" id="homeShaped"></div>
    <div style="display: none; width:950px; height:500px; background:url('http://jonesonter.notomato.com.au/wp-content/themes/jonesonter/img/home-page/sustained.jpg');" id="homeSustained"></div>
</div>

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

相关问题 JavaScript无法在IE8 / IE7中运行,但在其他所有浏览器中都可以正常运行 - JavaScript not working in IE8 / IE7 but fine in every other browser Javascript无法在IE中运行,但所有其他浏览器都可以正常运行 - Javascript not working in IE, but all other browsers are working fine 简单的javascript函数在IE7中不起作用 - Simple javascript function not working in IE7 javascript按钮在IE中不起作用; 在其他浏览器中工作 - Javascript button not working in IE; working in other browsers Ajax在下拉列表中无法在IE8中工作,但在其他浏览器中工作正常 - Ajax not working in IE8 on dropdown but it's working fine in other browsers JavaScript无法在IE上运行,但在所有其他浏览器中都可以 - JavaScript not working on IE, but OK in all other browsers Flash菜单的Javascript未在IE9中加载,但在所有其他浏览器中都可以正常运行 - Javascript for flash menu not loading in IE9 but fine in all other browsers 单击事件在 IE 中不起作用,但在其他浏览器中工作正常 - Click event is not working in IE but works fine in other browsers onclick 功能在 IE 中不起作用,但在其他浏览器上工作正常 - The onclick function is not working in IE but works fine on other browsers 我的Javascript代码在IE中不起作用,但在其他浏览器中也可以正常工作 - My Javascript code does not work in IE but works fine in other browsers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM