<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#box{
width: 100px;
height: 100px;
border: 1px black solid ;
}
</style>
</head>
<body>
<!-- 【】 完全等同于‘.’ -->
<p>
<input id="ip1" type="text">
<input id="ip2" type="text">
<button type="button" id="btn">改变</button>
</p>
<div id="box">
</div>
<script type="text/javascript">
var obox = document.getElementById('box');
var obtn = document.getElementById('btn');
var oip1 = document.getElementById('ip1');
var oip2 = document.getElementById('ip2');
obtn.onclick=function(){
obox.style[oip1.value]=oip2.value;
}
</script>
</body>
</html>
网友评论