<input type="button" value="改变颜色" OnClick="color()">
<input type="button" value="改变宽高" OnClick="WH()">
<input type="button" value="隐藏内容" OnClick="disshow()">
<input type="button" value="显示内容" OnClick="show()">
<input type="button" value="取消设置" OnClick="NO()">
</form>
<script type="text/javascript">
function color(){
var mychar = document.getElementById("txt");
mychar.style.color="red";
mychar.style.backgroundColor="#ccc";
}
function WH(){
var mychar=document.getElementById("txt");
mychar.style.width="250px";
mychar.style.height="250px";
}
function disshow(){
var mychar=document.getElementById("txt");
mychar.style.display="none";
}
function show(){
var mychar=document.getElementById("txt");
mychar.style.daiplay="block";
}
function NO(){
var mychar=document.getElementById("txt");
mychar.style.color="black";
mychar.style.bakcgroundColor="white";
mychar.style.width="600px";
mychar.style.height="400px";
}
倒数第二个函数最后一行的display拼错,最后一个函数不可以这样写,代码累赘,可以这样
var p1=document.getElementById("txt");
function CC(){
p1.style.color="red";
p1.style.backgroudColor="#CCC";
}
function CS(){
p1.style.width="400px";
p1.style.height="400px";
}
function hide(){
p1.style.display="none";
}
function show(){
p1.style.display="block";
}
已发现错误,是简单拼写错误