Html 분류
호버(hover) 할 때 jquery 이벤트 감지 방법
작성자 정보
- webveloper 작성
- 작성일
본문
안녕하세요.
html 코딩 시 hover 할때 감지하는 이벤트 스크립트입니다.
<style>
.con-group { display: flex; align-items: center; justify-content: space-around;}
.con-item { width: 100%; display: flex; flex-direction: column; color: #fff; font-size: 24px; cursor: pointer; transition: all .5s; margin: 0 10px; padding: 20px 0px 20px 40px; box-sizing: border-box; }
.con-item.active { background: #fff; border-radius: 10px; color: #002DAC; }
.con-item:hover { background: #fff; border-radius: 10px; color: #002DAC; }
</style>
<div class="con-group">
<div class="con-item active">
<span>1</span>
</div>
<div class="con-item">
<span>2</span>
</div>
<div class="con-item">
<span>3</span>
</div>
</div>
<script>
$(document).ready(function() {
$('.con-item').hover(function() {
$('.con-item:nth-child(1)').removeClass('active');
},
function() {
$('.con-item:nth-child(1)').addClass('active');
});
});
</script>
관련자료
댓글 0
등록된 댓글이 없습니다.