2022 SW 전문인재양성사업/웹 프로그래밍 기본
jQuery API (1) - 기초
마루설아
2022. 8. 2. 09:43
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>jQuery 실습 01</h1>
<div id="box">box</div>
<button id="changeBtn">Change</button>
<script src="http://code.jquery.com/jquery.js"></script>
<script>
$('#box').html("<h2>Hello</h2>");
// Getters와 Setters를 함께 사용
var html = $('#box').html();
var txt = $('#box').text();
console.log(html);
console.log(txt);
//$('#box').html($('#box').html() + "<h3>World</h3>");
$('#changeBtn').click(function(e){
$('#box').html(`<h2>${$('#box').text()} World</h2>`);
});
</script>
</body>
</html>