<!DOCTYPE?HTML>
<html>
<head>
<meta?http-equiv="Content-Type"?Content="text/html;?charset=utf-8"?/>
<title>javascript</title>
<style?type="text/css">
body{font-size:12px;}
#txt{
????height:400px;
????width:600px;
border:#333?solid?1px;
padding:5px;}
p{
line-height:18px;
text-indent:2em;}
</style>
</head>
<body>
??<h2?id="con">JavaScript?course</H2>
??<div?id="txt">?
?????<h5>JavaScript?index</h5>
????????<p>1.?JavaScript?elementary</p>
????????<p>2.?JavaScript?advanced</p>
????????<p>3.?more?functions</p>
??</div>
??<form>
??<!--當(dāng)點(diǎn)擊相應(yīng)按鈕,執(zhí)行相應(yīng)操作,為按鈕添加相應(yīng)事件-->
????<input?type="button"?value="change?color"?onclick="changecolor()">??
????<input?type="button"?value="change?size"?onclick="changesize()">
????<input?type="button"?value="hide?content"?onclick="hidecontent()">
????<input?type="button"?value="show?content"?onclick="showcontent()">
????<input?type="button"?value="remove?all?style"?onclick="remove()">
??</form>
??<script?type="text/javascript">
?? var?text=document.getElementById("txt");
//定義"改變顏色"的函數(shù)
function?changecolor(){
text.style.color="red";
text.style.backgroundColor="gray";
};
//定義"改變寬高"的函數(shù)
function?changesize?()?{
txt.style.width="200px";
txt.style.height="200px";
}
//定義"隱藏內(nèi)容"的函數(shù)
function?hidecontent?()?{
txt.style.display="none";
}
//定義"顯示內(nèi)容"的函數(shù)
function?showcontent?()?{
txt.style.display="block";
}
//定義"取消設(shè)置"的函數(shù)
function?remove?()?{
text.removeAttribute("style");
}
??</script>
</body>
</html>
2016-11-18
函數(shù)名remove換成其他的,我也是這個(gè)問題,換掉就可以了
2016-11-10
代碼輸錯(cuò)了兄弟,??txt.style.width="200px";請問這句是什么意思,是text吧
2016-11-07
IE8-11,edge成功運(yùn)行,沒問題
2016-11-07
2016-11-07
沒有吧 你重新打開試試 ?或者換個(gè)瀏覽器 ,我運(yùn)行了一下,沒有問題的啊。