首页 > 代码库 > -css Text

-css Text

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>

<style>
div { width:100px; height:100px; border:1px solid #333; }
</style>

</head>

<body>

<div id="div1">123</div>

<input id="btn1" type="button" value="http://www.mamicode.com/按钮" />

<script>
var oDiv = document.getElementById(‘div1‘);
var oBtn = document.getElementById(‘btn1‘);

oDiv.onclick = function (){
// oDiv.style.width = ‘200px‘;
oDiv.style.cssText = ‘ width:200px; height:200px; ‘;
};
oBtn.onclick = function (){
// oDiv.style.width = ‘100px‘;
oDiv.style.cssText = ‘‘;
};

</script>

</body>
</html>

-css Text