<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function () {
// 이벤트 bind() click() mouserover()
//$('선택자').bind('이벤트명', 이벤트처리함수정의);
$('h1').bind('mouseover', function () {
//$(this).append('+');
//$(this).html('<b>aaa</b>');
$(this).html(function (index, oldHtml) {
return oldHtml + '+';
});
});
// click 이벤트
//$('div').bind('click', function () {});
$('div').click(function () {
$(this).append("*");
});
});
</script>
</head>
<body>
<div>div0</div>
<div>div1</div>
<div>div2</div>
<h1>head0</h1>
<h1>head1</h1>
<h1>head2</h1>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function () {
// 메소드 체이닝으로 호출이 가능
// 대상.mouseover().mouseout();
// mouseover mouseout 이벤트
$('.img1').mouseover(function () {
$(this).attr('src', '../j1/dog.jpg');
}).mouseout(function () {
$(this).attr('src', '../j1/cat.png');
});
});
</script>
</head>
<body>
<img class="img1" src="../j1/cat.png" width="100" height="100">
</body>
</html>
'IT > jQuery' 카테고리의 다른 글
jQuery - form submit 이벤트 함수, event.preventDefault() (0) | 2018.11.17 |
---|---|
jQuery - textarea keyup 이벤트 (0) | 2018.11.16 |
jQuery - append(), appendTo(), prepend() (0) | 2018.10.13 |
jQuery - html(), text() (0) | 2018.10.13 |
jQuery - jQuery를 사용하여 css 적용하는 방법 (0) | 2018.10.12 |