<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div id = "stock" style="width:90px;height:20px;background:red;"></div>
<script type="text/javascript">
var str = "width: 90px;height: 20px;background: blue;";
document.getElementById("stock").style = str;
</script>
</body>
</html>
document.getElementById("stock").style.cssText = str;
已测试成功,非常感谢!