JS怎么根据动态表格的某列值修改另一列的字体颜色
RT,部分代码如下:<s:iteratorvalue="pages.fieldslist"><tdonmouseover="this.className='aa'"onm...
RT,部分代码如下:
<s:iterator value="pages.fieldslist">
<td onmouseover= "this.className= 'aa ' " onmouseout= "this.className= 'bb ' " class= "bb "><center><s:property value="devType.typeName" /></td>
<td onmouseover= "this.className= 'aa ' " onmouseout= "this.className= 'bb ' " class= "bb "><center><div id="name1"><s:if test="lightColor=='green'">green</s:if><s:if test="lightColor=='yellow'">yellow</s:if><s:if test="lightColor=='red'">red</s:if></div></td>
</tr>
</s:iterator>
struts2的,从action那传值到JSP,分别为green,yellow,red给lightcolor,然后想要的效果是根据传来的颜色改变typeName的字体颜色。 展开
<s:iterator value="pages.fieldslist">
<td onmouseover= "this.className= 'aa ' " onmouseout= "this.className= 'bb ' " class= "bb "><center><s:property value="devType.typeName" /></td>
<td onmouseover= "this.className= 'aa ' " onmouseout= "this.className= 'bb ' " class= "bb "><center><div id="name1"><s:if test="lightColor=='green'">green</s:if><s:if test="lightColor=='yellow'">yellow</s:if><s:if test="lightColor=='red'">red</s:if></div></td>
</tr>
</s:iterator>
struts2的,从action那传值到JSP,分别为green,yellow,red给lightcolor,然后想要的效果是根据传来的颜色改变typeName的字体颜色。 展开
1个回答
展开全部
var ChangeColor = {
change : function(){
var color_param = ${lightColor};
document.getElementById("需要变颜色的字体所在的容器ID").style.color = color_param ;
}
}
页面加载时调用 <body onload="ChangeColor.change()">
change : function(){
var color_param = ${lightColor};
document.getElementById("需要变颜色的字体所在的容器ID").style.color = color_param ;
}
}
页面加载时调用 <body onload="ChangeColor.change()">
更多追问追答
追问
木有反应。。我在var color_param = ${lightColor};下面加了alert(color_param);,没有弹出窗口。。何解。。
追答
函数估计没有被调用,这样,你写个简单的js函数,别用我的那种写法
var color_param = ${lightColor};
document.getElementById("需要变颜色的字体所在的容器ID").style.color = color_param ;
把这段代码放到页面标记前试试,同时alert()看一下是否取到了color_param值
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询