下拉列表文本在IE8中不可见 [英] Dropdownlist text is invisible in IE8

查看:111
本文介绍了下拉列表文本在IE8中不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些原因,我的DDL选项在IE8中都是不可见的。它们显然在那里,因为列表有127个选项,但文本是不可见的。在Firefox中,一切都很好。我甚至尝试在选择中设置内联样式,颜色设置为黑色!重要。当我用Firebug检查DDL时,它没有显示它继承任何样式,只显示我内联的内容。

For some reason my DDL options are all invisible in IE8. They're clearly there since the list has 127 options but the text is invisible. In Firefox everything shows up fine. I even tried putting an inline style on the select with the color set to black with !Important. When I inspect the DDL with Firebug it doesn't show it inheriting any styles, only what I've put inline.

我将var添加到循环的第一行如果它是某种传递引用问题,希望var基本上每次通过循环创建一个新变量,而不是以单个实例结束。这也不起作用,从我在javascript中使用var第二次读取的变量不会导致它变成新的变量。

I added var to the first line in the loop in case it was some kind of pass by reference issue, hoping that var would essentially create a new variable each time through the loop and not end up with a single instance. That didn't work either and from what I've read using var a second time on a variable in javascript does not cause it to become a new variable.

我' m填充数组中的下拉列表:

I'm populating the drop downs from an array:

var option = document.createElement("option");
option.textContent = "Select...";
option.value = 0;
departmentDropDownList.appendChild(option);

for (var i = 0; i < departments.length; i++)
{
    var option = document.createElement("option");
    option.textContent = departments[i][1];
    option.value = departments[i][0];
    departmentDropDownList.appendChild(option);
}


推荐答案

IE8 c> 财产。您必须为它进行垫片并使用 innerText

IE8 does not support the textContent property. You have to shim for it and use innerText instead.

option.textContent = option.innerText = departments[i][1];

这篇关于下拉列表文本在IE8中不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆