代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<script type='text/javascript'>
{
window.onload = function(){
initStyle();
addRecord();
searchRecord();
sortRecord();
}
//tBodies,tHead,tFoot,rows,cells
function initStyle(){
console.log('99999');
var table = document.getElementById('tab')
var trs = table.tBodies[0].rows;
for ( var i = 0; i < trs.length; i++ ){
//隔行变颜色
if(i%2 == 0){
trs[i].style.backgroundColor = '#ccc'
}
//鼠标移入变绿色,移出变原来的颜色
trs[i].onmouseover = function(){
oldColor = this.style.backgroundColor;
this.style.backgroundColor = 'green'
}
trs[i].onmouseout = function(){
this.style.backgroundColor = oldColor;
}
}
}
//添加
function addRecord(){
var btn = document.getElementById('btnAdd');
var table =