댓글 검색 목록

[javascript] 흐르는 글자 구현

페이지 정보

작성자 운영자 작성일 17-12-29 20:56 조회 1,386 댓글 0

HTML :

<p id="scroller"></p>



코드 :

function scroll(position) {
 var msg = "홈페이지제작강좌 - 웹학교!";
 var out = "";
 var sc = document.getElementById("scroller");
 for (var i=0; i < position; i++){
  out += msg.charAt(i);
 }
 out += msg.charAt(position);
 sc.innerHTML = out;
 position++;
 if (position != msg.length) {
  window.setTimeout(function() { scroll(position); }, 50);
 }
 else {
  window.setTimeout(function() { scroll(0); }, 2000);
 }
}
scroll(0);



댓글목록 0

등록된 댓글이 없습니다.

웹학교 로고

온라인 코딩학교

코리아뉴스 2001 - , All right reserved.