<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
</head>
<body>
<!-- mouseover, mouseout -->
<!-- //JS -->
<!-- <h3 class="cls" onmouseover="mouseOver()"
onmouseout="mouseOut()"> h3 tag </h3> -->
<!-- //JQ -->
<h3 class="cls" style="background-color: #00ff00;"> h3 tag </h3>
<script type="text/javascript">
//JS
function mouseOver(){ //커서가 위로 올라갔을때
alert("범위에 들어 왔습니다");
}
//JQ
$(document).ready(function(){
$(".cls").mouseover(function(){
// alert("범위에 들어 왔습니다");
// $(".cls").css("background", "#ffff00");
$(this).css("background", "#0000ff"); //내가 접근한것이 cls클래스의 태그라면 적용됨
});
$(".cls").mouseout(function(){
// alert("범위에 들어 왔습니다");
// $(".cls").css("background", "#ffff00");
$(this).css("background", "#00ff00"); //내가 접근한것이 cls클래스의 태그라면 적용됨
});
});
</script>
</body>
</html>
'프로그래밍 > jQuery' 카테고리의 다른 글
hide, show 세부 설정 (0) | 2020.01.10 |
---|---|
hide함수 활용_this (0) | 2020.01.10 |
태그 마우스 클릭 시 반응_this, click (0) | 2020.01.10 |
버튼을 누를시 상태변화_textfield/setget (0) | 2020.01.10 |
jQuery 버튼 호출 (0) | 2020.01.10 |