SetColor Case
2018-10-06 本文已影响0人
Jadon7
<!DOCTYPE html>
<html>
<head>
<title>setColor</title>
</head>
<style type="text/css">
#reactangle{
width:300px;
height:300px;
background:red;
}
</style>
<body>
<input type="button" value="变红" onclick="setColor('red')">
<input type="button" value="变绿" onclick="setColor('green')">
<input type="button" value="变黑" onclick="setColor('black')">
<div id="reactangle"></div>
<script type="text/javascript">
var oReactangle=document.getElementById('reactangle');
function setColor(color)
{
oReactangle.style.background=color;
}
</script>
</body>
</html>