<style type="text/css">
a:link,a:visited{
color:#00F;
text-decoration:none;
}
a:hover{
color:#FBB;
}
#newstext{
border:#000 1px solid;
width:400px;
padding:10px;
}
.normal{
font-size:16px;
color:#099;
background-color:#13C0EC;
}
.max{
color:#303;
font-size:24px;
}
.min{
color:#333;
font-size:9px;
}
</style>
</head>
<body>
<script type="text/javascript">
function changeFont(class1)//不能用class 与关键字冲突不能使用了
{
var oNewsText = document.getElementById("newstext");
oNewsText.className = class1;
}
function changeFont2(class1)//不能用class 与关键字冲突不能使用了
{
var oNewsText = document.getElementById("newstext");
oNewsText.className = class1;
}
</script>
<h1>新闻标题</h1>
<hr />
<a href="javascript:void(0)" onclick="changeFont('max')">大字体</a>
<a href="javascript:void(0)" onclick="changeFont('normal')">中字体</a>
<a href="javascript:void(0)" onclick="changeFont('min')">小字体</a>
<div id="newstext" >
这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容
这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容
这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容
这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容
这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容
这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容
这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容
这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容
这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容
这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容这是新闻内容
</div>
</body>
<script type="text/javascript">
window.onload = function trColor()
{
tabNode = document.getElementById("tableid");
var collTrNode = tabNode.rows;
for(var x= 1; x<collTrNode.length;x++)
{
if(x%2==1)
{
collTrNode[x].className="one";
}
else
{
collTrNode[x].className="two";
}
collTrNode[x].onmouseover=function()
{
name = this.className;
this.className = "over";
}
collTrNode[x].onmouseout=function()
{
this.className = name;
}
}
}
var name;
</script>
<script type="text/javascript">
function sorttab()
{
var oTabNode = document.getElementById("tableid");
var collTrNode = oTabNode.rows;
var trArr = [];
for(var x=1 ; x<collTrNode.length;x++)
{
trArr[x-1] = collTrNode[x];
}
mySort(trArr);
if(flag)
{
for(var x=0;x<trArr.length;x++)
{
trArr[x].parentNode.appendChild(trArr[x]);
}
flag = false;
}
else
{
for(var x=trArr.length-1;x>=0;x--)
{
trArr[x].parentNode.appendChild(trArr[x]);
}
flag = true;
}
}
var flag=true;
function mySort(arr)
{
for (var x = 0;x<arr.length-1;x++)
{
for (var y = x+1;y<arr.length;y++)
{
if(parseInt(arr[x].cells[1].innerHTML)>parseInt(arr[y].cells[1].innerHTML))
{
var temp = arr[x];
arr[x] = arr[y];
arr[y] =temp;
}
}
}
}
</script>
</head>
<body>
<table id="tableid">
<tr>
<th>姓名</th>
<th><a href="javascript:void(0)" onclick="sorttab()">年龄</a></th>
<th>地址</th>
</tr>
<tr onmouseover="over(this)" onmouseout="out(this)">
<td>张苏纳</td>
<td>11</td>
<td>天堂</td>
</tr>
<tr>
<td>小白</td>
<td>14</td>
<td>上号</td>
</tr>
<tr>
<td>如果</td>
<td>8</td>
<td>玩玩</td>
</tr>
<tr>
<td>是</td>
<td>18</td>
<td>大岸</td>
</tr>
</table>
</body>