取消設置按鈕不管用
<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")
2016-08-12
??function exit() {
? ? ? ?var quxiao = true;
? ? ? ?if(quxiao ==?confirm("你要取消設置嗎"))
? ?{.......
2016-08-12
我覺得是你的exit函數內沒有定義mycolor、myweight、hide、show這幾個,可以在這里面重新?var hide = document.getElementById("txt"),或者將你的var mycolor = document.getElementById("con")這些語句全放到函數外應該就好了。