JavaScript变高、变宽、变颜色、重置、隐藏、显示小练习

原创 2018-11-05 22:49:28 286
摘要:<!DOCTYPE html><html> <head> <meta charset="utf-8"> <title></title> <style> #dex{ width: 100px; height: 100px; background: cadetblue;

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title></title>

<style>

#dex{

width: 100px;

height: 100px;

background: cadetblue;

margin: 0 auto;

}

.Input{

text-align: center;

margin: 20px;

}

</style>

</head>

<body>

<div id="dex"></div>

<div class="Input">

<input type="button" value="变高" onclick="vHeight()"/>

<input type="button" value="变宽" onclick="vWidth()"/>

<input type="button" value="变色" onclick="vCor()"/>

<input type="button" value="重置" onclick="vSe()"/>

<input type="button" value="隐藏" onclick="vHide()"/>

<input type="button" value="出现" onclick="vShow()"/>

</div>

</body>

<script>

var dex;

function vHeight(){

dex=document.getElementById('dex');

dex.style.height='400px';

}

function vWidth(){

dex=document.getElementById('dex');

dex.style.width='400px';

}

function vCor(){

dex=document.getElementById('dex');

dex.style.background='red';

}

function vSe(){

dex=document.getElementById('dex');

dex.style.width='100px';

dex.style.height='100px';

dex.style.background='cadetblue';


}

function vHide(){

dex=document.getElementById('dex');

dex.style.display='none';

}

function vShow(){

dex=document.getElementById('dex');

dex.style.display='block';

}

</script>

<!--谢谢老师指导,老师辛苦了 感谢php中文网-->

</html>


批改老师:灭绝师太批改时间:2018-11-06 09:03:52
老师总结:不辛苦……课余时间可以多练习一些其他的例子

发布手记

热门词条