목차
this 예제 - 현재 요소 선택 this 정의
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $(this).hide(); }); }); </script> <h2>홈짱닷컴</h2> <p>Homzzang.com</p> <p>홈페이지 제작관리</p> <button>클릭</button> 결과보기
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$(this).hide();
});
</script>
<h2>홈짱닷컴</h2>
<p>Homzzang.com</p>
<p>홈페이지 제작관리</p>
<button>클릭</button>
결과보기
※ 여기서 this는 button 요소 가리킴.
현재 선택된 HTML 요소 의미.