<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>이벤트 - 부모 자식 요소 영향 단계</title>
<script src="jquery-3.6.0.min.js"></script>
<style type="text/css">
* {
	margin: 10px;
	padding: 10px;
}

.inner {
	background: orange;
}

.outer {
	background: lightgreen;
}
</style>
<script type="text/javascript">
	$(document).ready(function() {
		$(".wrap1").mouseover(function() { // 부모요소에게 이벤트 적용시 자식에게도 적용됨
			$(".result").append("<strong>마우스 오버</strong>")
		})
		$(".wrap2").mouseenter(function() {
			$(".result").append("<em>마우스 엔터</em>")
		})
	});
</script>
</head>
<body>
	<div class="wrap1 outer">
		<div class="inner">마우스 오버</div>
	</div>
	<div class="wrap2 outer">
		<div class="inner">마우스 엔터</div>
	</div>
	<div class="result"></div>
</body>
</html>

'HTML·CSS' 카테고리의 다른 글

[HTML, CSS] jQuery 트리거 액션  (2) 2021.08.17
[HTML, CSS] jQuery 이용한 갤러리  (0) 2021.08.17
[HTML,CSS] jQuery를 이용한 아코디언 액션  (0) 2021.08.17
DOM , BOM 개념 정리  (0) 2021.08.12
[HTML CSS] 기본 구조  (0) 2021.08.10

+ Recent posts