<html>
<body>
<script type="text/网页特效">
function chcolor(){
document.getelementbyid("t").style.color="red";
}
</script>
<div id="t">
怎么改变字体颜色
</div>
<a href="javascript:chcolor();">设置我为红色</a>
</body>
</html>
//方法二
<head> <title> 变颜色字体 </title>
<script language= "javascript ">
function bcolor()
{
var a=document.all.color1;
if(a.style.color!= "red ")
a.style.color= "red ";
}
</script>
</head>
<body>
<form name= "yuan ">
<span id= "color1 "> 袁浩琳 </span>
<input type= "button " value= "单击 " onclick= "bcolor();"></form>
时间: 2024-10-26 01:22:34