以下这段代码是w3c的方法,没有问题。鄙人根据所学知识,也写了段代码。感觉道理上是可以执行的,但为啥就不行呢?
<html>
<body>
<script>
function ChangeBackground()
{document.body.style.backgroundColor="lavender";}
</script>
<input type="button" onclick="ChangeBackground()"
value="Change background color" />
</body>
</html>
以下是鄙人写的代码,为什么就执行不了呢?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
function abc()
{
var a=document.getElementsByTagName('body');
a.style.color='red';
}
</script>
</head>
<form>
<input type="button" value="点击按钮改变背景颜色" onclick="abc()"/>
</form>
</body>
</html>
Tang小溪
weibo_哆啦A梦有大口袋_0
随时随地看视频慕课网APP
相关分类