카테고리 없음

javascript 글자색상 변경

jiwno 2022. 9. 23. 17:41
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <h2 id="hello">여보세요</h2>
    
    <script>
      
        document.getElementById('hello').innerHTML = '안녕하세요';
        document.getElementById('hello').style.fontSize = "35px";
        document.getElementById('hello').style.color = "red";
        
    </script>
    
</body>
</html>

style.color = "red" "blue" "green" 과 같은 색상이름도 되지만

style.color = "FF0000" "FFFF00" 이런 식의 헥스코드값도 가능함