第4个回答 2017-09-29
<style type="text/css">
span{
display:inline-block;
*display:inline-block;
zoom:1;
}
.bg{
width:300px;
height:20px;
border-radius:10px;
background:#3D3C3A;
}
.main{
/* width:70%; */
height:20px;
border-radius:10px;
background:#55404C;
}</style>
==============================================
<script>
function assign(){
var _width = document.getElementById("percent").innerText;
alert(_width);
document.getElementById("changed").style.width = _width;
}
</script>
==========================================
<BODY>
<span class="bg">
<span class="main" id="changed"></span>
</span>
<span class="num" id="percent">70%</span>
<input type="button" value="赋值" onclick="assign()">
</body>