[개발]프로그래밍/jquery
[jquery] hover() - 마우스가 올라왔을 때,떠났을 때
좋은 블로그
2016. 10. 17. 08:33
1. hover() - 역할
객체에 마우스가 올라왔을 때, 즉 rollover 되었을 때와 마우스가 객체로부터 떠났을 때, 즉 leave가 되었을 때 발생하는 이벤트
2. hover() - 예제
◈ 코드
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <script src="https://code.jquery.com/jquery-1.11.3.js" type="text/javascript"></script> <script> $(document).ready(function () { $('h1').hover(function(){ $(this).css('color','blue'); }, function() { $(this).css('color','red'); }); }); </script> <body> <h1>test1</h1> <h2>test2</h2> </body> |
◈ 결과화면
- 아무 작업도 하지 않은 처음 화면
- 마우스를 올렸을 때
- 마우스를 떠났을 때