js實現(xiàn)網(wǎng)頁換膚
更新時間:2022年07月01日 17:08:19 作者:標準形與二次型
這篇文章主要為大家詳細介紹了js實現(xiàn)網(wǎng)頁換膚功能,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了js實現(xiàn)網(wǎng)頁換膚的具體代碼,供大家參考,具體內(nèi)容如下
效果:

代碼:
<!DOCTYPE html>
<html>
?? ?<head>
?? ??? ?<meta charset="utf-8">
?? ??? ?<title></title>
?? ??? ?<style type="text/css">
?? ??? ??? ?*{
?? ??? ??? ??? ?margin: 0px;
?? ??? ??? ??? ?padding: 0px;
?? ??? ??? ?}
?? ??? ??? ?body{
?? ??? ??? ??? ?height: 100%;
?? ??? ??? ??? ?width: 100%;
?? ??? ??? ??? ?
?? ??? ??? ?}
?? ??? ??? ?#main{
?? ??? ??? ??? ?height: 720px;
?? ??? ??? ??? ?width: 100%;
?? ??? ??? ??? ?background-color: pink;
?? ??? ??? ?}
?? ??? ??? ?button{
?? ??? ??? ??? ?height: 15px;
?? ??? ??? ??? ?width: 15px;
?? ??? ??? ??? ?border: 1px solid #fff;
?? ??? ??? ??? ?margin: 10px 10px;
?? ??? ??? ??? ?
?? ??? ??? ?}
?? ??? ??? ?#red{
?? ??? ??? ??? ?background-color: red;
?? ??? ??? ?}
?? ??? ??? ?#green{
?? ??? ??? ??? ?background-color: green;
?? ??? ??? ?}
?? ??? ??? ?#blue{
?? ??? ??? ??? ?background-color: blue;
?? ??? ??? ?}
?? ??? ??? ?
?? ??? ?</style>
?? ?</head>
?? ?<body>
?? ??? ?<div id="main">
?? ??? ??? ?<button type="button" id="red" onclick="red()"></button>
?? ??? ??? ?<button type="button" id="green" onclick="green()"></button>
?? ??? ??? ?<button type="button" id="blue" onclick="blue()"></button>
?? ??? ?</div>
?? ??? ?
?? ??? ?<script type="text/javascript">
?? ??? ??? ?var x=document.getElementById('main');
?? ??? ??? ?function red(){
?? ??? ??? ??? ?x.style.backgroundColor='red';
?? ??? ??? ??? ?
?? ??? ??? ??? ?document.getElementById('red').style.border="3px solid white";
?? ??? ??? ??? ?document.getElementById('green').style.border="1px solid white";
?? ??? ??? ??? ?document.getElementById('blue').style.border="1px solid white";
?? ??? ??? ??? ?
?? ??? ??? ?}
?? ??? ??? ?function green(){
?? ??? ??? ??? ?x.style.backgroundColor='green';
?? ??? ??? ??? ?document.getElementById('green').style.border="3px solid white";
?? ??? ??? ??? ?document.getElementById('red').style.border="1px solid white";
?? ??? ??? ??? ?document.getElementById('blue').style.border="1px solid white";
?? ??? ??? ?}
?? ??? ??? ?function blue(){
?? ??? ??? ??? ?x.style.backgroundColor='blue';
?? ??? ??? ??? ?document.getElementById('blue').style.border="3px solid white";
?? ??? ??? ??? ?document.getElementById('red').style.border="1px solid white";
?? ??? ??? ??? ?document.getElementById('green').style.border="1px solid white";
?? ??? ??? ?}
?? ??? ?</script>
?? ?</body>
</html>以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
JavaScript實現(xiàn)動態(tài)刪除列表框值的方法
這篇文章主要介紹了JavaScript實現(xiàn)動態(tài)刪除列表框值的方法,涉及javascript針對select列表框的遍歷與刪除操作技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-08-08
關(guān)于Javascript 對象(object)的prototype
Javascript中的每個對象(object)都會有 prototype,下面為大家介紹下其具體的應(yīng)用2014-05-05
詳解JS數(shù)據(jù)類型的值拷貝函數(shù)(深拷貝)
這篇文章主要介紹了詳解JS數(shù)據(jù)類型的值拷貝函數(shù)(深拷貝)的相關(guān)資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2017-07-07
使用BootStrap實現(xiàn)表格隔行變色及hover變色并在需要時出現(xiàn)滾動條
這篇文章主要介紹了使用BootStrap實現(xiàn)表格隔行變色及hover變色并在需要時出現(xiàn)滾動條效果,代碼簡單易懂,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2017-01-01
JavaScript實現(xiàn)秒數(shù)轉(zhuǎn)換時間的兩種格式
在開發(fā)過程中,經(jīng)常會遇到后臺接口返回的是以秒為單位的數(shù)據(jù),而我們需要將其轉(zhuǎn)換為一個更加易讀的格式,本文將介紹如何實現(xiàn)秒數(shù)轉(zhuǎn)時間的兩種格式,有需要的可以參考下2025-02-02
XHTML-Strict 內(nèi)允許出現(xiàn)的標簽
XHTML-Strict 內(nèi)允許出現(xiàn)的標簽...2006-12-12

