How to force ie8 to repaint after adding a class to a dom element

后端 未结 6 993
旧时难觅i
旧时难觅i 2021-02-01 05:52

In ie8 if elements don\'t \'repaint\' with the associated css when you change the classname, how can you force the browser to refresh and not kill ie8 performance?

This

6条回答
  •  名媛妹妹
    2021-02-01 06:45

    The solution I came up with for my ie8 issue was to add/remove a class on a near parent of the element i'm changing. Since I'm using modernizer, I check for ie8 and then do this add/remove dance to get the new css to paint.

            $uicontext.addClass('new-ui-look');
            if ($('html').is('.ie8')) {
                // IE8: ui does not repaint when css class changes
                $uicontext.parents('li').addClass('z').removeClass('z');
            }
    

提交回复
热议问题