不久之前,我在IE8上遇到了这个问题。
我认为这可能是IE8无法重新渲染有问题的元素的问题。一种简单的确认方法是将一个类添加到父元素,然后将其删除。这将触发IE8重新渲染元素。
如果contentBlock是父元素,则可以使用以下命令进行测试:
Javascript版本:
// Variable storing the test class namevar testClass = "testClass";// Add test class to elementcontentBlock.className += " "+testClass;// Remove test class from elementvar reg = new RegExp('(\s|^)'+testClass+'(\s|$)');contentBlock.className=contentBlock.className.replace(reg,' ');jQuery版本:
// Variable storing the test class namevar testClass = "testClass";// Add test class to element and then remove it $('#divResults').addClass(testClass).removeClass(testClass);在您添加appendChild之后,只需将其放在函数末尾即可。希望这可以解决您的问题。
参考:http :
//www.openjs.com/scripts/dom/class_manipulation.php



