//定义"改变颜色"的函数
function gbys(){
txt.style.color="red";
txt.style.backgroundColor="pink";
}
//定义"改变宽高"的函数
function gbkg(){
txt.style.width="400px";
txt.style.height="300px"
}
//定义"隐藏内容"的函数
function ycnr(){
txt.style.display="none";
}
//定义"显示内容"的函数
function xsnr(){
txt.style.display="block";
}
//定义"取消设置"的函数
function qxsz(){
if (confirm("是否取消设置?")){
txt.style.color="#000";
txt.style.backgroundColor="#fff";
txt.style.weidth="600px";
txt.style.height="400px";
txt.style.display="block";
}
}
例隐藏内容:
根本不需要定义 var yc = document.getElementById("txt");
yc.style.display="none";
直接用 txt.style.display="none"; 也可以啊,那为什么要定义
var yc = document.getElementById("txt");
变量虽然也可以不声明,直接使用,但不规范,所有需要先声明,后使用。