728x90
반응형
<!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">
<script src="../js/jquery.min.js"></script>
<style>
</style>
<script>
$(document).ready(function(){
$("#gnb>li>a").on({"mouseover":function(){
var idx=$("#gnb>li>a").index(this)
var menuIdx = "메뉴"+(idx+1)
console.log(menuIdx)
},
"mouseout":function(){
console.log("out!")
}
})
})
</script>
<title>Document</title>
</head>
<body>
<ul id="gnb">
<li><a href="#">메뉴1</a></li>
<li><a href="#">메뉴2</a></li>
<li><a href="#">메뉴3</a></li>
<li><a href="#">메뉴4</a></li>
</ul>
</body>
</html>
<a>태그에 mouseover 될때마다 index값 콘솔출력
<a>태그에서 mouseout 될때마다 "out!" 콘솔출력
728x90
반응형
'HTML+CSS(복습)' 카테고리의 다른 글
2023-05-17(수) show , hide , toggle (0) | 2023.05.17 |
---|---|
2023-05-16(화) off(이벤트해제) (0) | 2023.05.17 |
2023-05-16(화) click , index (0) | 2023.05.17 |
2023-05-16(화) keydown (0) | 2023.05.17 |
2023-05-16(화) change , value(이메일) (0) | 2023.05.17 |