ELEMENT.style.color无法在IE中运行

时间:2022-11-20 21:47:11

In a small web application I'm setting some text in a text box and its color using JavaScript.

在一个小型Web应用程序中,我使用JavaScript在文本框中设置一些文本及其颜色。

In the following snipped, el is my object. This code produces the correct effects under Firefox, Opera and Safari but no such luck under IE. I've been searching without success since most examples say to use x.style.color="color", which I'm using. My text shows up correctly but the color is grayed out.

在下面的剪辑中,el是我的对象。此代码在Firefox,Opera和Safari下生成正确的效果,但在IE下没有这样的运气。我一直在寻找没有成功,因为大多数例子都说使用x.style.color =“color”,我正在使用它。我的文字显示正确,但颜色显示为灰色。

The object is a disabled, borderless text box. I get no errors or warnings.

该对象是禁用的无边框文本框。我没有错误或警告。

el.value = "TEXT"; el.style.color="blue";

el.value =“TEXT”; el.style.color = “蓝色”;

2 个解决方案

#1


In IE, you can't change the text color of a disabled text box

在IE中,您无法更改禁用文本框的文本颜色

#2


Use JQUERY

$('#el').css("color", "blue");

This code should solve your problem.

此代码应该可以解决您的问题。

#1


In IE, you can't change the text color of a disabled text box

在IE中,您无法更改禁用文本框的文本颜色

#2


Use JQUERY

$('#el').css("color", "blue");

This code should solve your problem.

此代码应该可以解决您的问题。