728x90

<!DOCTYPE html>
<head>
</head>
<body>
	<p id="aa">자바스크립트 넘나 재밌는 것 </p>

	<script>
		let n=document.getElementById('aa');
		let m=setInterval("on()",500); 
		//0.5초 주기로 on함수 호출

		n.onclick=function(){
			clearInterval(m); //타이머 해제
		}
		function on(){
			let a=n.innerHTML;  
			let b=a.substr(0,1); //
			let c=a.substr(1, a.length-1);
			a=c+b;
			n.innerHTML=a;
		}


	</script>
</body>
</html>
728x90

'Language > JavaScript' 카테고리의 다른 글

[JS] HTML DOM Node  (0) 2024.04.03
[JS] 예시  (0) 2024.04.03
[JS] window, location 객체 메소드  (0) 2024.04.02
[JS] 문서 객체 모델 (DOM) 이벤트 처리  (0) 2024.04.02
[JS] 문서 객체 모델(DOM) 2  (0) 2024.04.02

+ Recent posts