简体   繁体   中英

JQuery - addClass() not working for IE10+

I have created a javascript function which fades in a number of elements when the page is scrolled down to a specific point. This is done by adding the class "active" (with addClass) to the relevant elements which would then fade them in via CSS.

On IE10+ JQuery addClass() does not appear to work. I am stumped as to why!

    var fadeServiceList = function(sT, wH) {
        var $home_why_us = $('.home-why-us'),
            $theshold = $home_why_us.offset().top;

        if (sT > $theshold - ( wH / 2 ) ) {
            $('#line').addClass('active');
            $home_why_us.find('.service-list ul').addClass('active');
        }
    };

I would appreciate your help pointing me in the right direction!

Cheers, Jim.

Internet Explorer 11 (possibly other versions) ignores the first application of .addClass() if the target element: is one of the following inline elements: label, strong, span, em contains an input element (any type) contains text within another inline element such as: label, strong, span, em It behaves properly in other browsers.

function highlight(){
    $("label").addClass("highlight");
}

FIDDLE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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