jQuery fadeIn, fadeOut effects in IE

左心房为你撑大大i 提交于 2019-12-10 09:27:14

问题


The below fadeIn, fadeOut effect works fine in Firefox 3.0 but it doesn't work in IE 7 ... Whay is that and what's the trick? The idea is of course to get a "blink" effect and attract the attention of the user to a specific row in a table.

function highLightErrorsAndWarnings() {
            $(".status-error").fadeIn(100).fadeOut(300).fadeIn(300).fadeOut(300).fadeIn(300).fadeOut(300).fadeIn(300);
            $(".status-warning").fadeIn(100).fadeOut(300).fadeIn(300).fadeOut(300).fadeIn(300).fadeOut(300).fadeIn(300);
        }

Update: Found the stupid problem ... ".status-error" points to a tr-element. It's possible to the set the background-color and fade it on a tr in Firefox but not in IE. Changing the "CSS pointer" to ".status-error td" made it point to the td below the tr and everything worked in all browsers.


回答1:


Weird.. couldn't tell you why you're getting that problem, but maybe try the pulsate effect plugin? http://docs.jquery.com/UI/Effects/Pulsate




回答2:


I have a similar issue but I can't select the td's instead for various reasons.

If you are also affected you might try using show instead of fadeIn. Since I'm using the similarly broken fadeTo this doesn't help me either :(

There is a jQuery bug open here - http://dev.jquery.com/ticket/5451

If you are affected please comment on the ticket.




回答3:


Well, i have experimented with various ways to address this issue. The down and dirty approach that I use is to detect background and foreground color on text and just animate the div/span/etc with color change.

This snippet will "pulsate" the text once (you can create a function that does it more times by :

$.fn.crossBrowserPulsate = function() {
    var startColor = $(this).css("background-color");
    var endColor = $(this).css("color");

    $(this).animate({color:startColor},500,
     function() {
      $(this).animate({color:endColor},500,
       ...
      )}
    );
}


来源:https://stackoverflow.com/questions/353100/jquery-fadein-fadeout-effects-in-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!