반응형
<!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>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    
</head>
<style>

</style>
<body>
    <span>A</span>
    <h1>A</h1>
    <span id ="myId">A</span><br>
    <span class="myClass">A</span>
    <script>
        $(document).ready(function(){
            $('*').css('font-size','32px')// 전체 요소 선택
            $('h1').css('color','red');
            $('#myId').css('color','blue');
            $('.myClass').css('color','green');
        });
    </script>
</body>
</html>

jQuery의 선택자(태그명, ID명, 클래스명)를 선택해 속성을 변경하는 예시입니다.

$('선택자').css('속성', '속성값'); 

 

반응형