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';
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
[2022.04.19] 자바스크립트 this - 생성자 함수와 이벤트리스너에서의 this18일에 this에 대해 공부하면서 적었던 일반적인 함수나 객체에서의 this가 아닌 오늘은 이벤트리스너와 생성자 함수 안에서의 this를 살펴보기로 했다. new 키워드를 붙여 함수를 생성자로 사용할 때 this는...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.