输入的JS没有运行 请大牛指教
一直都对DOM很难懂 请大牛指教一下要点
2016-08-24
<input type="button" value="改变颜色" onclick="changeColor()">
<input type="button" value="改变宽高" onclick="changeW_H()">
<input type="button" value="隐藏内容" onclick="noneContent()">
<input type="button" value="显示内容" onclick="displayContent()">
<input type="button" value="取消设置" onclick="setRest()">
var conChar = document.getElementById("con");
var txtChar = document.getElementById("txt");
var color = conChar.style.color;
var width = conChar.style.width;
var height = conChar.style.height;
var dis = conChar.style.display;
//定义"改变颜色"的函数
function changeColor(){
conChar.style.color="red";
}
//定义"改变宽高"的函数
function changeW_H(){
conChar.style.width = "1000px";
conChar.style.height = "20px";
}
//定义"隐藏内容"的函数
function noneContent(){
txtChar.style.display = "none";
}
//定义"显示内容"的函数
function displayContent(){
txtChar.style.display = "block";
}
//定义"取消设置"的函数
function setRest(){
var sign = confirm("确定取消设置?");
if(sign) {
conChar.style.color = color;
conChar.style.width = width;
conChar.style.height = height;
txtChar.style.display = dis;
}
}
举报