<!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>
<p>p tag</p>
<div>
<p>div in p tag 1</p>
<p>div in p tag 2</p>
<p class="cls">div in p tag class cls</p>
</div>
<script type="text/javascript">
$(function (){
/* $('p').click(function (){
// alert('p tag click');
});
$('div p').click(function (){
alert('div p tag click');
});
*/
/* $('div .cls').click(function (){ //div태그 안의 클래스 cls
alert('div p tag click');
}); */
$('p').on("click", function(){
// $(this).hide(); //hide는 감춰지는 것 . this를 해주면 클릭이된 오브젝트가 숨겨짐
$(this).css("background","#ff0000" ); // setter (property명, value)
var color = $(this).css("background"); //getter
alert(color);
});
});
</script>
</body>
</html>