Struts 2 标签实现奇偶行变色,js 实现鼠标滑过变色
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户列表页面</title>
<style type="text/css">
.row-odd{background-color:#c8e7a6;}
.row-even{background-color:#def7c2;}
</style>
<script type="text/javascript">
function alterBgColor(a)
{
a.style.backgroundColor="#DEE7FF";
}
function restore(a,f)
{
//判定奇偶行实现变色
if(f==true)
{a.style.backgroundColor="#c8e7a6";}
else
{a.style.backgroundColor="#def7c2";}
}
</script>
</head>
<body>
<h2>用户列表页面</h2>
<table>
<s:iterator value="users" status="st">
<tr onmouseover="alterBgColor(this)"
onmouseout="restore(this,<s:if test="#st.odd">true</s:if><s:else>false</s:else>)"
class="<s:if test="#st.odd">row-odd</s:if><s:else>row-even</s:else>">
<td align="right"><s:property value="id" /></td>
<td align="left"><s:property value="username" /><td>
</tr>
</s:iterator>
</table>
<s:debug></s:debug>
</body>
</html>