1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="utf-8">
    <script src="js/jquery.js"></script>
</head>
<body>
    <div style="background:blue; text-align:center; width:300px; height:300px; font-size: 30px; font-weight: bold; line-height: 300px;">
        안녕하세요
    </div>
 
    <script>
        
        // inline 속성으로 적용된 css 프로퍼티 개별삭제
       $("div").css("background-color","");
       $("div").css("font-weight","");
       $("div").css("text-align","");
 
        
        // inline 속성으로 적용된 style 전체삭제
        // $( 'div' ).removeAttr( 'style' );
 
        
        //순수 자바스크립트의 removeProperty메서드로 css 개별삭제
        // var div = $('div').get(0);
        // div.style.removeProperty('text-align');     
        // div.style.removeProperty('line-height');     
            
    </script>
</body>
</html>


반응형
Posted by 힘없는염소