日期:2014-05-16  浏览次数:20376 次

CSS input button 的问题
直接代码吧


//----------------------------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css"> //###


tbody {color:green;height:50px text-align:center}

table
  {
  border-collapse:collapse;
  height:20px;
  }

table, td, th
  {
  border:1px solid green;
  }
td
{
text-align:center;
height:25px;
}
th 
{
color:green height:50px
   background-color:green;

}

</style>  //####
<script type="text/javascript">
function createData(){
var a={};
for(var i=0;i<256;i++){
a[i+".name"]=i+"name";
a[i+".age"]=i+'age';
a[i+".sex"]=((i&1)==0?'男':'女');
}
return a;
}
function createTable(){
for(var i=0;i<=19;i++){
var tr=document.createElement("tr");
for(var j=0;j<=2;j++){
tr.appendChild(document.createElement("td"));
}
document.getElementById("data").appendChild(tr);
}
}
function findData(x,data){
var tds=document.getElementsByTagName("td");
var j=0;
for(var i=(x-1)*20;i<x*20;i++){
tds[j++].innerHTML=data[i+'.name'];
tds[j++].innerHTML=data[i+'.age'];
tds[j++].innerHTML=data[i+'.sex'];
}
}
window.onload=function(){
var data=createData();
var isInit=false;
var f=document.getElementById("find");
var p=document.getElementById("page");
var n=document.getElementById("next");
var r=document.getElementById("pre");
f.onclick=function(){
if(!isInit){
createTable();
p.value=1;
isInit=true;
}
findData(p.value,data);
}
r.onclick=function(){
if(!isInit){
createTable();
p.value=1;
isInit=true;
}else{
p.value=parseInt(p.value)-1;
}
findData(p.value,data);
}
n.onclick=function(){
if(!isInit){
createTable();
isInit=true;
p.value=1;
}else{
p.value=parseInt(p.value)+1;
}
findData(p.value,data);
}
}
</script>
</head>

<body>
<div id="test">
<table>
     <tbody id="data">
         <tr>
             <th>姓名</th>
                <th>年龄</th>
                <th>性别</th>
            </tr>
        </tbody>
    </table>
</div>
<input type="button" value="查询" id="find" />
<input type="button" value="上一页" id="pre" />
<input type="button" val