DEV/jQuery
hide함수 활용_this
purple
2020. 1. 10. 16:42

<!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>
<p id="pid">p tag id pid</p>
<p class="cls">p tag class cls</p>
<p name="_name">p tag name_name</p>
<button type="button">click</button>
<script type="text/javascript">
// id 는 확인용 class는 css에 name은 값을 불러올때 자주 사용된다.
$(document).ready(function(){
$("p").click(function(){
console.log( $(this).text()); //p테크를 눌렀을 때 콘솔에 text를 getter로 받아온다.
});
$("button").click(function (){
// $('p').hide();
// $("*").hide();
// $("p#pid").hide();
// $('p.cls').hide();
$('p[name=_name]').hide(); //네임 접근법
});
});
</script>
</body>
</html>