[問題] 請問如何按下button後在指定區塊顯示圖片

看板Ajax作者 (織夢精靈)時間11年前 (2012/09/10 23:02), 編輯推噓0(002)
留言2則, 2人參與, 最新討論串1/1
標題好像下的怪怪的! 我先把我打的貼上來 <button id="start" style="width:120px;height:75px;">Start</button> <div id="show" style="border:1px solid black;width:120px;height:75px;margin: 0px auto;"> <script language="javascript"> document.getElementById("start").onclick=function(){click()}; function click(){var n = Math.floor(Math.random()*1000)%16+1; document.writeln("<img src="+n+".jpg>") } </script> </div> 我是想按下button之後 在<div></div>這裡裡面區塊顯示隨機亂數n的圖片 可是這樣寫,按下去後是只顯示圖片 其他網頁中的內容都消失了0.0 document.writeln("<img src="+n+".jpg>") 應該是這行出了問題 可是卻不知道怎麼改.... 想在原本頁面然後指定區塊顯示圖片! 麻煩各位高手了~ 感激不盡 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.33.25.58

09/10 23:18, , 1F

09/11 11:10, , 2F
感恩~
09/11 11:10, 2F
文章代碼(AID): #1GJW416Y (Ajax)