댓글 검색 목록

[javascript] 왼쪽에서 오른쪽으로 문자열 회전하는 프로그램을 작성하시오.

페이지 정보

작성자 운영자 작성일 17-12-29 21:55 조회 1,390 댓글 0

HTML :

<!DOCTYPE html>
  <html> 
  <head>
  <title>JavaScript basic animation</title>
  <script type="text/javascript">
  </script>
  </head> <body onload="animate_string('target')"
  <pre id="target">365OK웹학교 </pre>
  </body> 
  </html>


코드 : 

function animate_string(id) 
{
    var element = document.getElementById(id);
    var textNode = element.childNodes[0]; // assuming no other children
    var text = textNode.data;

setInterval(function () 
{
 text = text[text.length - 1] + text.substring(0, text.length - 1);
  textNode.data = text;
}, 100);
}



댓글목록 0

등록된 댓글이 없습니다.

웹학교 로고

온라인 코딩학교

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