点击改变背景

<!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=gb2312" />
<title>无标题文档</title>
</head>
<style type="text/css">
.bgred{
 background:#F00;
 }
.bgyellow{
 background:#FF0;
 }
#mm a{
 width:200px;
 height:25px;
 background:#FFF;
 }
</style>
<script>
function onclickbg(tdid){
 document.getElementById(tdid).className='bgyellow';
 }
function oncblurbg(tdid){
 document.getElementById(tdid).className='bgred';
 }
</script>
<body>
<table width="600" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="40" align="center" class="bgred" id="mm1"><strong><a href="#"  onclick="onclickbg('mm1')" onblur="oncblurbg('mm1')">你好</a></strong></td>
    <td height="40" align="center"  class="bgred"  id="mm2"><strong><a href="#"  onclick="onclickbg('mm2')" onblur="oncblurbg('mm2')">你好</a></strong></td>
    <td height="40" align="center"  class="bgred"  id="mm3"><strong><a href="#"  onclick="onclickbg('mm3')" onblur="oncblurbg('mm3')">你好</a></strong></td>
  </tr>
</table>
</body>
</html>
by 雪洁 2010-09-10 09:29:14 2425 views
我来说几句

相关文章