jquery 05 mouseenter()와 mouseleave() 메소드
프론트엔드/Jquery2021. 3. 17. 21:22
마우스 이벤트 알아보기
0
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
var n=0;
$(document).ready(function() {
$("div.out").mouseenter(function(){
$("p:first", this).text("마우스 포인트 들어옴");
$("p:last", this).text(++n);
});
$("div.out").mouseleave(function(){
$("p:first", this).text("마우스 포인트 나감");
$("p:last", this).text("최종 횟수: " +n);
});
});
</script>
<style>
div.out{
width: 200px;
height : 100px;
border:1px solid #000000;
text-align: center;
background-color: yellow;
}
</style>
</head>
<body>
<div class="out">
<p> 마우스 이벤트 알아보기</p>
<p>0</p>
</div>
</body>
</html>
'프론트엔드 > Jquery' 카테고리의 다른 글
jquery 07 addClass()와 removeClass()메소드 (0) | 2021.03.18 |
---|---|
jquery 06 mousedown()와 mouseup() 메소드 (0) | 2021.03.17 |
jquery 04 mouseenter() 메소드 (0) | 2021.03.17 |
jquery 03 퀴즈 프로그램 만들기 (0) | 2021.03.17 |
jquery 02 다중 이벤트 처리하기 (0) | 2021.03.17 |
댓글()