且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在将类添加到dom元素后强制ie8重绘

更新时间:2023-12-02 23:32:34

我为ie8问题提出的解决方案是在我正在改变的元素的近父级上添加/删除一个类。由于我正在使用现代化器,我检查ie8,然后执行此操作添加/删除舞蹈以获取新的css进行绘制。

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');
        }