소프트웨어 이론교육/웹 프로그래밍 기본

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>

 

 

'소프트웨어 이론교육 > 웹 프로그래밍 기본' 카테고리의 다른 글

jQuery API (3) - map  (0) 2022.08.02
jQuery API (2) - 기초2  (0) 2022.08.02
jQuery (4) - 장바구니 구현, localStorage  (0) 2022.08.01
jQuery (3) - 기초2  (0) 2022.08.01
jQuery (2) - callback  (0) 2022.08.01