JS 홈 페이지 스킨 케 어

4497 단어 js
웹 페이지 의 스킨 케 어 란 다른 스타일 로 바 꾸 는 것 이다.
물론 css + js 작업 과 결합 하여 완성 해 야 합 니 다.
bg1.css 

body {background-color:black;}
bg2.css 

body {background-color:red;}
 

<!
DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <link id="linkcss" href="css/bg1.css" rel="stylesheet" type="text/css"/> </head> <body> <input type="button" value=" 1" id="btnStyle1" /> <input type="button" value=" 2" id="btnStyle2" /> </body> </html>

피 부 를 바 꾸 려 면 동적 으로 링크 를 바 꾸 는 href 만 있 었 으 면 좋 겠 어 요.
 window.onload=function(){
            document.getElementById('btnStyle1').onclick=function(){
                document.getElementById('link1').href='css1.css'; 
            }
            document.getElementById('btnStyle2').onclick=function(){
                document.getElementById('link1').href='css2.css'; 
            }
          
        }

좋은 웹페이지 즐겨찾기