<input type="button" value="改变颜色" onclick="color()">
<input type="button" value="改变宽高" onclick="wh()">
<input type="button" value="隐藏内容" onclick="hide()">
<input type="button" value="显示内容" onclick="show()">
<input type="button" value="取消设置" onclick="exit()">
</form>
<script type="text/javascript">
function color() {
var mycolor = document.getElementById("con")
mycolor.style.color = "blue"
mycolor.style.backgroundColor = "black"
}
function wh() {
var myweight = document.getElementById("txt")
myweight.style.width = "100px"
myweight.style.height = "600px"
}
function hide() {
var hide = document.getElementById("txt")
hide.style.display = "none"
}
function show() {
var show = document.getElementById("txt")
show.style.display = "block"
}
function exit() {
var quxiao = confirm("你要取消设置吗")
if(quxiao == true)
{
mycolor.removeAttribute("style")
myweight.removeAttribute("style")
hide.removeAttribute("style")
show.removeAttribute("style")
function exit() {
var quxiao = true;
if(quxiao == confirm("你要取消设置吗"))
{.......
我觉得是你的exit函数内没有定义mycolor、myweight、hide、show这几个,可以在这里面重新 var hide = document.getElementById("txt"),或者将你的var mycolor = document.getElementById("con")这些语句全放到函数外应该就好了。