作者justlovegirl (织梦精灵)
看板Ajax
标题[问题] 请问如何按下button後在指定区块显示图片
时间Mon Sep 10 23:02:15 2012
标题好像下的怪怪的!
我先把我打的贴上来
<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
2F:→ justlovegirl:感恩~ 09/11 11:10