<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel = "stylesheet" href = "../css/mystyle.css" type="text/css">
<script src="/jqpro/js/jquery-3.6.0.min.js" type="text/javascript"></script>
<script>
function proc1(){
var elem = document.getElementById('result1');
elem.style.background = 'blue';
$(elem).css('background', 'green');
}
$(function(){
$('#btn').on('click', function(){
var elem = document.getElementById('result2');
$(elem).css('background', 'yellow');
var jq = $('#result2');
jq.css('background', 'pink');
})
})
</script>
</head>
<body>
<div class = "box">
이벤트 설정<br>
1. 태그요소에서 : <button type = "button"><br>
<br>
<button type = "button" onclick="proc1()">확인</button>
<div id = "result1"></div>
</div>
<div class = "box">
이벤트 설정<br>
2. script에서 :
$('#btn').on('click', function(){ })<br>
$('button').eq(1).on('click', function(){ })
<br>
<button type = "button" id="btn">확인</button>
<div id = "result2"></div>
</div>
</body>
</html>