css 링크를 스크립트를 활용하여 동적으로 설정할 수 있다.
// 링크 객체 생성 var cssNode = document.createElement("link"); cssNode.type = "text/css"; cssNode.rel = "stylesheet"; // 스타일 시트 파일 경로 설정 cssNode.href = "test.css"; cssNode.id = "dynamicLink"; // 생성 링크 head 태그에 삽입 document.head.appendChild(cssNode);
'Web > Javascript' 카테고리의 다른 글
동적 HTML 삽입 (0) | 2015.11.11 |
---|---|
동적 스타일 적용 및 해제 (0) | 2015.11.11 |
IE 에서 window.getSelection() 실행 되지 않을 때~ (0) | 2015.08.26 |
Grunt 설치 및 js파일 통합 (0) | 2014.10.29 |