2个回答
展开全部
<body id="body">
<script language="javascript">
function docolor(type){
alert(type);
var obj=document.getElementById('mydiv');
switch(type){
case 1:
obj.style.backgroundColor="red";
break;
case 2:
obj.style.backgroundColor="blue";
break;
}
}
</script>
<a href="javascript:docolor(1)">红色</a>
<a href="javascript:docolor(2)">蓝色</a>
<hr />
<div id="mydiv" style="width:%00px; height:500px; border:1px #000 2px;">这里的颜色?</div>
</body>
<script language="javascript">
function docolor(type){
alert(type);
var obj=document.getElementById('mydiv');
switch(type){
case 1:
obj.style.backgroundColor="red";
break;
case 2:
obj.style.backgroundColor="blue";
break;
}
}
</script>
<a href="javascript:docolor(1)">红色</a>
<a href="javascript:docolor(2)">蓝色</a>
<hr />
<div id="mydiv" style="width:%00px; height:500px; border:1px #000 2px;">这里的颜色?</div>
</body>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询