想不通為什么removeAttribute前面接txt就可以運行, 而換成div就不可以
? <script type="text/javascript">
//定義"改變顏色"的函數(shù)
function but(){
? ? var box=document.getElementById("txt")
? ??
? ? box.style.color="red"
? ? box.style.backgroundColor="#ccc"
}
//定義"改變寬高"的函數(shù)
function but1(){
? ? var box=document.getElementById("txt")
? ??
? ? box.style.width="320px"
? ? ? box.style.height="450px"
?}
? ? ??
//定義"隱藏內(nèi)容"的函數(shù)
? function but2(){
? ? ? var box=document.getElementById("txt")
? ? ? box.style.display="none"
? }
//定義"顯示內(nèi)容"的函數(shù)
function but3(){
? ? var box=document.getElementById("txt")
? ??
? ? box.style.display="block"
}
//定義"取消設(shè)置"的函數(shù)
function but4(){
? ? var box=confirm("你確定重置所有屬性")
? ? if(box!=null){
? ? ? txt.removeAttribute("style") ?
? ? }
}
2015-03-04
少俠 ?div不是html的標簽名么