单击按钮使文字变大,代码如下,结果报错
<html>
<head>
<title></title><script language="javascript">
function chan()
{
var mspan=document.getElementById("sp");
mspan.style.font-size="50px";
}
</script>
</head>
<body>
<p>正点</p>
<span id="sp" style="font-size:9px; display:display;">hello</span>
<input type="button" value="变大" onclick="chan();"/>
</body>
</html>
<html>
<head>
<title></title><script language="javascript">
function chan()
{
var mspan=document.getElementById("sp");
mspan.style.font-size="50px";
}
</script>
</head>
<body>
<p>正点</p>
<span id="sp" style="font-size:9px; display:display;">hello</span>
<input type="button" value="变大" onclick="chan();"/>
</body>
</html>
<head>
<title></title><script language="javascript">
function chan()
{
var mspan=document.getElementById("sp");
mspan.style.fontSize="50px";
}
</script>
</head>
<body>
<p>正点</p>
<span id="sp" style="font-size:9px; display:display;">hello</span>
<input type="button" value="变大" onclick="chan();"/>
</body>
</html>
比如背景色:css: background-color:'blue';
js应用: style.backgroundColor = 'blue';
这样就 OK 了