📄 4-13.html
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<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">
function color(e)
{
switch(e.srcElement.id){ //获得标记的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>
<div id="first" onMouseOver="color(event);" onMouseOut="clearText(event);">我本将心照明月</div>
<br>
<div id="second" onMouseOver="color(event);" onMouseOut="clearText(event);">奈何明月照沟渠</div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -