重置函数有对话框,但是点击确定后不起作用。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>mission</title>
<style type="text/css">
body {
font-size: 12;
}
#txt {
height: 333px;
width: 500px;
border: red solid 2px;
padding: 5px;
}
p {
line-height: 20px;
text-indent: 2em;
}
</style>
</head>
<body>
<h1 id="demo1">JavaScript</h1>
<div id="txt">
<h5>我也不知道这要干嘛</h5>
<p>7.Your rejection taught me courage.</p>
<p>8.Whether you view me as a hero or a villain,</p>
<p>9.please know that I poured every emotion,every bit of passion and my entire self into being a Laker,</p>
</div>
<form>
<input type="button" value="改变颜色" onclick="changeColor()" />
<input type="button" value="改变宽高" onclick="ser.changeSize()" />
<input type="button" value="隐藏内容" onclick="ser.hideText()" />
<input type="button" value="显示内容" onclick="ser.showText()" />
<input type="button" value="取消设置" onclick="ser.OffSet()" />
</form>
<script type="text/javascript">
var txt = document.getElementById("txt");
function changeColor() {
txt.style.color = "goldenrod";
txt.style.backgroundColor = "blanchedalmond";
}
var ser = {
changeSize: function() {
txt.style.width = "600px";
txt.style.height = "200px";
},
hideText: function() {
txt.style.display = "none";
},
showText: function() {
txt.style.display = "block";
},
OffSet: function() {
var message = confirm("你确定要重置所有设置么?");
if (message == true) {
txt.removeAttribute('style');
}
}
}
</script>
</body>
</html>