본문 바로가기

JavaScript&Web

[JavaScript] click 이벤트 발생 예제


실제 예제



<html>
<head>
<meta http-equiv="Content-Type" content="text⁄html; charset=EUC-KR">
<style>
	.reverse{
	background: Black;
	color: White;
	}
<⁄style>
<script src="http:⁄⁄code.jquery.com⁄jquery-1.7.js"><⁄script>
<script>
	$(document).ready(function() {
		⁄⁄이벤트를 연결함
		 $('h1').bind('click',function(){  ⁄⁄bind 는 함수를 모아놓은 것 클릭할때
			 $(this).html(function (index,html){
				 return html +'*';  ⁄⁄  * 가 하나씩 추가됨
			 });
		 });
		
		$('h1').bind({  ⁄⁄이벤트를 연결함
mouseenter:function (){ $(this).addClass('reverse');},			
mouseleave:function (){ $(this).removeClass('reverse');}
		});
	});
<⁄script>

<⁄head>
<body>
	<h1>Header-0<⁄h1>
	<h1>Header-1<⁄h1>
	<h1>Header-2<⁄h1>
<⁄body>
<⁄html>



결과 화면