我用处数据库里调出的数据构建成表格,如何设置鼠标悬浮变色,离开有便会原来的颜色???
求教各位高手!!function addTableRow(id, name, permissions,i){
var tab = document.getElementById("personList");
hang = tab.insertRow(); if(i%2==0)
hang.className = "blue";
lie = hang.insertCell(0);
lie.innerHTML = i+1;
lie = hang.insertCell(1);
lie.innerHTML = id;
lie = hang.insertCell(2);
lie.innerHTML = name;
lie = hang.insertCell(3);
lie.innerHTML = permissions;
lie = hang.insertCell(4);
lie.innerHTML = "<input type='button' class='Button' onClick='' value='修改'/>";
}
求教各位高手!!function addTableRow(id, name, permissions,i){
var tab = document.getElementById("personList");
hang = tab.insertRow(); if(i%2==0)
hang.className = "blue";
lie = hang.insertCell(0);
lie.innerHTML = i+1;
lie = hang.insertCell(1);
lie.innerHTML = id;
lie = hang.insertCell(2);
lie.innerHTML = name;
lie = hang.insertCell(3);
lie.innerHTML = permissions;
lie = hang.insertCell(4);
lie.innerHTML = "<input type='button' class='Button' onClick='' value='修改'/>";
}
hang.onmouseover = function(obj){
return function(){obj.style.backgroundColor = "red";};
}(hang);
if(i%2==0){
hang.className = "blue";
hang.onmouseout = function(obj){
return function(){obj.style.backgroundColor = "blue";};
}(hang);
}else{
hang.onmouseout = function(obj){
return function(){obj.style.backgroundColor = "white";};
}(hang);
}
<html>
<script type="text/javascript">
var n =0;
var cur;
function addTableRow(id, name, permissions,i){
var tab = document.getElementById("personList");
var hang = tab.insertRow();
hang.style.backgroundColor = "#FFF"
hang.onmouseover = function(){
cur = this.style.backgroundColor;
this.style.backgroundColor = "yellow";
};
hang.onmouseout = function(obj){
this.style.backgroundColor = cur;
};
if(i%2==0) hang.style.backgroundColor = "blue";
lie = hang.insertCell(0);
lie.innerHTML = i+1;
lie = hang.insertCell(1);
lie.innerHTML = id;
lie = hang.insertCell(2);
lie.innerHTML = name;
lie = hang.insertCell(3);
lie.innerHTML = permissions;
lie = hang.insertCell(4);
lie.innerHTML = "<input type='button' class='Button' onClick='' value='修改'/>";}</script>
</head><body>
<input type="button" value="add" onclick="addTableRow(1,'xx','xx',n++)">
<table id="personList">
</table>
</body>
</html>
function addTableRow(id, name, permissions,number,i){
var tab = document.getElementById("personList");
hang = tab.insertRow();
hang.onmouseover=function(){
this.style.backgroundColor="#fbf4a2"
}
hang.onmouseout=function(){
this.style.backgroundColor=""
}
if(i%2==0)
hang.className = "blue";
lie = hang.insertCell(0);
lie.innerHTML = number;
lie = hang.insertCell(1);
lie.innerHTML = id;
lie = hang.insertCell(2);
lie.innerHTML = name;
lie = hang.insertCell(3);
lie.innerHTML = permissions;
lie = hang.insertCell(4);
lie.innerHTML = "<input type='button' class='Button' onClick='' value='修改'/>";
}