CSS doesn't apply to dynamically created elements in IE 7?

后端 未结 7 1496
不思量自难忘°
不思量自难忘° 2021-02-13 10:32

Still looking for an answer.

Changing or reassigning to the filter\'s innerHTML successfully redraws the element, but breaks my script, so that\'s out.

7条回答
  •  情书的邮戳
    2021-02-13 11:27

    Sounds to me like you need to force a redraw of the UI for this element. There are several ways to do this, but the following is the most effective method...

    // elm is a reference to your element
    var disp = elm.style.display;
    elm.style.display = "none";
    var redrawFix = elm.offsetHeight;
    elm.style.display = disp;
    

    Here is another method I found on Ajaxian...

    function redraw(elm) {
      var n = document.createTextNode(' ');
      elm.appendChild(n);
      setTimeout(function(){ n.parentNode.removeChild(n) }, 0);
      return elm;
    }
    

提交回复
热议问题