您的位置:首页 > 其它

DOM的事件处理---学习笔记

2007-06-04 10:08 447 查看
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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 runat="server">
<title>无标题页</title>
<style type="text/css">
.red
{
color:red;
font-style:italic;
font-size:32;
}
.blue
{
color:blue;
font-size:36;
}
.black
{
color:black;
}
</style>

<script language="javascript" type="text/javascript">
function color(e)
{
switch(e.srcElement.id)
{
case "first":
document.getElementById("first").className="red";
break;
case "second":
document.getElementById("second").className="blue";
break;
}
}
function clearText(e)
{
switch(e.srcElement.id)
{
case "first":
document.getElementById("first").className="black";
break;
case "second":
document.getElementById("second").className="black";
break;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="first" onmouseover="color(event);" onmouseout="clearText(event);">我本将心照明月</div><br />
<div id="second" onmouseover="color(event);" onmouseout="clearText(event);;">奈何明月照沟渠</div>
</form>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: