代码差不多,为什么不行呢?
<form>
<input type="button" value="改变颜色" onClick="dcolor()">
<input type="button" value="改变宽高" onClick="dwh()">
<input type="button" value="隐藏内容" onClick="dh()">
<input type="button" value="显示内容" onClick="ds()">
<input type="button" value="恢复" onClick="dclear()">
</form>
<script type="text/javascript">
function dcolor()
{ var mychar = document.getElementById("txt");
mychar.style.color="red";
mychar.style.backgroundColor="#ccc";
}
function dwh(){
var mychar=document.getElementById("txt");
mychar.style.width="300px";
mychar.style.height="600px";
}
function dh(){
var mychar=document.getElementById("txt");
mychar.style.display="none";
}
function ds(){
var mychar=document.getElementById("txt");
mychar.style.display="block";
}
function dclear(){
var mm=confirm("是否恢复原始设置:");
if(mm==true)
{ mydd.className="txt"; }
}
</script>
</body>
</html>