最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當(dāng)前位置: 首頁 - 科技 - 知識百科 - 正文

分享一篇關(guān)于JS的實例代碼

來源:懂視網(wǎng) 責(zé)編:小采 時間:2020-11-27 20:19:50
文檔

分享一篇關(guān)于JS的實例代碼

分享一篇關(guān)于JS的實例代碼:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Ty
推薦度:
導(dǎo)讀分享一篇關(guān)于JS的實例代碼:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Ty

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標(biāo)題文檔</title>
<style>
.dv { width:800px; height:600px; text-align:center;}
.td2 { width:80px; height:30px; border:solid #CCC 1px; background:#F00; color:#FFF; text-align:center; position:relative;}
.dv1 { width:150px; height:150px; border:solid #000 3px;}
.dv2 { width:300px; height:250px; border:solid #CCC 20px; position:absolute; top:100px; left:460px; display:none; background:#FFF;}
.td3 { width:30px; height:30px; border:solid #999 1px; text-align:center; color:#FFF;}
.td4 { width:30px; height:30px; border:solid #999 1px; text-align:center; color:#666; background:#CCC;}
.td5 { width:60px; height:30px; border:solid #999 1px; text-align:center; color:#FFF; background:#009;}
.tb { padding-left:70px; padding-top:20px;}
</style>
<script>
window.onload=function(){
var td1=document.getElementById("td");
var dv0=document.getElementById("dva");
var dv1=document.getElementById("dvv");
var dv2=document.getElementById("dve");
var color1=document.getElementById("c1");
var color2=document.getElementById("c2");
var color3=document.getElementById("c3");
var width1=document.getElementById("w1");
var width2=document.getElementById("w2");
var width3=document.getElementById("w3");
var height1=document.getElementById("h1");
var height2=document.getElementById("h2");
var height3=document.getElementById("h3");
var re=document.getElementById("recover");
var su=document.getElementById("sure");

td1.onclick=function(){
dv2.style.display='block';
dv0.style.background='#999999';
}

color1.onclick=function(){
dv1.style.background='#F00';
}
color1.onmouseover=function(){
color1.style.background='#F00';
}
color1.onmouseout=function(){
color1.style.background='#99CC66';
}

color2.onclick=function(){
dv1.style.background='#FF0';
}
color2.onmouseover=function(){
color2.style.background='#FF0';
}
color2.onmouseout=function(){
color2.style.background='#CCCC00';
}

color3.onclick=function(){
dv1.style.background='#00F';
}
color3.onmouseover=function(){
color3.style.background='#00F';
}
color3.onmouseout=function(){
color3.style.background='#3399CC';
}

width1.onclick=function(){
dv1.style.width='200px';
}
width1.onmouseover=function(){
width1.style.background='#F90';
}
width1.onmouseout=function(){
width1.style.background='#CCC';
}

width2.onclick=function(){
dv1.style.width='300px';
}
width2.onmouseover=function(){
width2.style.background='#F90';
}
width2.onmouseout=function(){
width2.style.background='#CCC';
}

width3.onclick=function(){
dv1.style.width='400px';
}
width3.onmouseover=function(){
width3.style.background='#F90';
}
width3.onmouseout=function(){
width3.style.background='#CCC';
}

height1.onclick=function(){
dv1.style.height='200px';
}
height1.onmouseover=function(){
height1.style.background='#F90';
}
height1.onmouseout=function(){
height1.style.background='#CCC';
}

height2.onclick=function(){
dv1.style.height='300px';
}
height2.onmouseover=function(){
height2.style.background='#F90';
}
height2.onmouseout=function(){
height2.style.background='#CCC';
}

height3.onclick=function(){
dv1.style.height='400px';
}
height3.onmouseover=function(){
height3.style.background='#F90';
}
height3.onmouseout=function(){
height3.style.background='#CCC';
}

re.onclick=function(){
dv1.style.width='150px';
dv1.style.height='150px';
dv1.style.background='none';
}

su.onclick=function(){
dv2.style.display='none';
dv0.style.background='none';
}
}
</script>
</head>

<body>
<div id="dva" class="dv">
<table>
<tr>
<td>
<strong>請為下面的DIV設(shè)置樣式:</strong>
</td>
<td id="td" class="td2">
點擊設(shè)置
</td>
</tr>
</table>
<div id="dvv" class="dv1">
</div>
<div id="dve" class="dv2">
<table cellspacing="10px">
<tr>
<td>請選擇背景顏色:</td>
<td id="c1" class="td3" bgcolor="#99CC66">紅</td>
<td id="c2" class="td3" bgcolor="#CCCC00">黃</td>
<td id="c3" class="td3" bgcolor="#3399CC">藍(lán)</td>
</tr>
<tr>
<td>請選擇寬(px):</td>
<td id="w1" class="td4">200</td>
<td id="w2" class="td4">300</td>
<td id="w3" class="td4">400</td>
</tr>
<tr>
<td>請選擇高(px):</td>
<td id="h1" class="td4">200</td>
<td id="h2" class="td4">300</td>
<td id="h3" class="td4">400</td>
</tr>
</table>
<table class="tb" cellspacing="10px">
<tr>
<td id="recover" class="td5">恢復(fù)</td>
<td id="sure" class="td5">確定</td>
</tr>
</table>
</div>
</div>
</body>
</html>

聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

分享一篇關(guān)于JS的實例代碼

分享一篇關(guān)于JS的實例代碼:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Ty
推薦度:
標(biāo)簽: 分享 js 代碼
  • 熱門焦點

最新推薦

猜你喜歡

熱門推薦

專題
Top