亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

創建一個函數,點擊頁面的左下角的按鈕可以更換body的背景圖片,可是一直無法實現,大神給看看

創建一個函數,點擊頁面的左下角的按鈕可以更換body的背景圖片,可是一直無法實現,大神給看看

慕粉3398407 2016-05-26 18:38:53
<!DOCTYPE?html> <html> <head> <meta?charset="utf-8"> <meta?http-equiv="X-UA-Compatible"?content="IE=Edge"> <meta?name="viewport"?content="width=device-width,?initial-scale=1"> <title>全球搜索,有問必應?(Bing)</title> <style?type="text/css"> *{margin:?0;padding:?0;font-family:?"微軟雅黑";list-style:none;} a:link{color:?lightgrey;} a:hover{color:?white;} body{background:?url(senlin.jpg)?fixed;background-position:center?center;overflow:hidden} .nav{background-color:#444444;width:100%;height:45px;?} .leftNav{margin-left:30px;} .leftNav?a{text-decoration:?none;font-size:13px;float:?left;width:60px;height:45px;line-height:45px;list-style:none;text-align:center;} .teshu?a{width:90px;float:?left;font-size:?12px;height:?45px;} .logo{background:?url(logo.png);width:107px;height:?53px;float:?left;margin:120px??0??0?100px;} .shuru{border:0;height:50px;line-height:50px;width:450px;font-color:?black;float:?left;margin:120px??0??0?15px;font-size:20px;} .subMit{border:0;height:50px;line-height:50px;width:55px;font-color:?black;float:?left;background-image:url(search-button.jpg);margin:120px?0?0?0;} .button1{width:50px;height:50px;float:?right;margin-right:?200px;margin-top:?500px;} </style> <body?id="main"> ????<div> ????????<div> ????????????<ul> ????????????????<li><a?href="#">圖片</a></li> ????????????????<li><a?href="#">視頻</a></li> ????????????????<li><a?href="#">學術</a></li> ????????????????<li><a?href="#">詞典</a></li> ????????????????<li><a?href="#">地圖</a></li> ????????????????<li><a?href="#">更多</a></li> ????????????????<li><a?href="#">|</a></li> ????????????</ul> ????????????<ul> ????????????????<li><a?href="#">OfficeOnline</a></li> ????????????????<li><a?href="#">Outlook.com</a></li> ????????????</ul> ???????? ????????</div> ???????? ????????<div> ???????? ????????</div> ????</div> ????<div>???? ????</div> ????<form> ????????<input?type="text"></input> ????????<input?type="submit"?value=""></input> ????</form> ????<div> ????????<img??src="button1.png"?onclick="changeImage()"?> ????</div> <!--下面是準備創建的函數--> <script> ????function?changeImage() ????{ ????var?n?=?Math.round((Math.random()*4)); ????var?imgChange?=?document.getElementById("main"); ????switch?(n) ????{ ????????case?1: ????????imgChange.style.background?=?url("animals.jpg"); ???????? ????????case?2: ????????imgChange.style.background?=?url("cayuyuan.jpg"); ????????break; ????????case?3: ????????imgChange.style.background?=?url("lake.jpg"); ????????break; ????????case?4: ????????imgChange.style.background?=?url("gui.jpg"); ????????break; ????????default: ????}???? } </script> </body>
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 1531 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號