<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script src = "http://code.jquery.com/jquery-1.11.2.min.js"></script>
</head>
<body>
<div id="container">
</div>
<p> prepend를 사용하여 사진을 순환합니다. </p>
<button id ="append" title="append">append</button>
<script>
i=0;
$("#append").click(function(e) {
i++;
if(i<6){
$("div#container").append( fetchImg() )
}else{
//document.write();
i=1;
}
});
function fetchImg(){
var n = Math.ceil( Math.random()*3 );
var imgPath = "<img src='img/pic" + n +".gif' width='100' height='100' />";
return imgPath ;
}
</script>
</body>
</html>
(주석처리한부분을 봐주시면 됩니다!)
중요한건 그 줄을 바꾸는 방법을 모르겠습니다..
document.write("<br>"); 을 넣으면 아예 뜨질 않는데
애초에 구상자체를 잘못한걸까요?
만약 줄을 바꾸는 태그가 있다면 알려주셨으면 합니다.
ㅇ아예 잘못된것이라면 잘못됐다고만 말해주셨으면 해요! 혼자 해보려구요 ㅠㅠ