<style type="text/css">
#div1{100px;height:100px;}
#div2{background}
</style>
<div id="div1">1212</div>
<div id="div2">3434</div>
<script>
function getStyle(obj,attribute){//获取样式
return obj.currentStyle?obj.currentStyle[attribute]/*ie*/:document.defaultView.getComputedStyle(obj,null)[attribute]/*ie9 火狐 谷歌*/;
}
var div1 = document.getElementById("div1");
var div2 = document.getElementById("div2");
var wid = getStyle(div1,"width")
div2.onmouseover = function(){//鼠标移到div2时设置宽度
this.style.width = wid;
};
</script>