<html lang="ko">
<head>
<meta charset="UTF-8">
<title>jQuery Element Access</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
$(function() {
$("button").on("click", function() {
var newText = $("h1").html(); // <h1>요소의 텍스트를 읽어오는 getter 메소드
$("#text").html(newText); // id가 "text"인 요소에 새로운 텍스트를 설정하는 setter 메소드
});
});
</script>
</head>
<body>
<h1>.html() 메소드</h1>
<p>아래의 버튼을 누르면 다음 단락에 새로운 텍스트를 설정할 수 있어요!!</p>
<button>새로운 텍스트!</button>
<p id="text"></p>
</body>
</html>