0

我可以更改从 100 小部件获得的此代码段的颜色吗?我希望(喜欢)图像颜色为 2a5500(绿色),文本为白色。

4

1 回答 1

0

我不明白,你到底是什么意思,但无论如何你可以使用elem.style.backgroundand elem.style.color

例子:

HTML:

<div id="elem" style="width:400px; height:250px; border:1px solid"> Welcome </div>

Javascript:

var elem = document.getElementById('elem');
elem.onmouseover = function(){
  elem.style.background = "#2a5500";
  elem.style.color = "#ff0080";
}
elem.onmouseout = function(){
  elem.style.background = "";
  elem.style.color = "";
}
于 2012-07-09T18:03:03.773 回答