1、利用css来改变的例子
<head>
<script>
function stylechange(stylename)
{changestyle.classname=stylename;}
</script>
<style>
<!--
.style1 { font-family: georgia; }
.style2 { font-family: 宋体; }
-->
</style>
</head>
<span onclick=stylechange("style1") style="cursor:hand">样式1</span>
<span onclick=stylechange("style2") style="cursor:hand">样式2</span>
<table>
<tr>
<td id=changestyle>
1981年11月19日
</td>
</tr>
</table>
2、又一个实时改变样式的例子:
<script language=javascript>
function fontchange(fontsize)
{
document.getelementbyid('fontchange').style.fontsize=fontsize+'px'
}
</script>
<a href="javascript:fontchange(48)">click here</a>
<span id="fontchange">1981年11月19日</span>