본문 바로가기
HTML 태그 & CSS 속성

[jQuery] CSS 프로퍼티 삭제

by 찬찬2 2021. 4. 27.

programmer-seva.tistory.com/61

 

[스터디_자바스크립트] 48. DOM 심화 - CSS 스타일시트와 CSS 규칙

1. CSS 스타일시트 개요 스타일시트는 외부 스타일시트를 포함하도록 HTMLLinkElement 노드를 사용하거나(예: ) 인라인 스타일시트를 정의하도록 HTMLStyleElement 노드(예: )를 사용하여 추가한다. 1 2 3 4 5

programmer-seva.tistory.com

 

 

<!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>



출처: https://mylife365.tistory.com/110 [변화에 적응하기]

댓글