為什么我的寬高無(wú)法設(shè)置?
? ? <input type="button" value="改變顏色" onClick="color()"> ?
? ? <input type="button" value="改變寬高" onClick="width()">
? ? <input type="button" value="隱藏內(nèi)容" onClick="displayNone()">
? ? <input type="button" value="顯示內(nèi)容" onClick="displayBlock()">
? ? <input type="button" value="取消設(shè)置" onClick="set()">
? </form>
? <script type="text/javascript">
//定義"改變顏色"的函數(shù)
function color(){
document.getElementById("txt").style.color="red";
}
//定義"改變寬高"的函數(shù)
function width(){
document.getElementById("txt").style.width="500px"; ?
document.getElementById("txt").style.height="300px";
}
//定義"隱藏內(nèi)容"的函數(shù)
function displayNone(){
document.getElementById("txt").style.display="none"; ? ?
}
//定義"顯示內(nèi)容"的函數(shù)
function displayBlock(){
document.getElementById("txt").style.display="block"; ? ?
}
//定義"取消設(shè)置"的函數(shù)
function set(){
if(confirm("是否進(jìn)行恢復(fù)操作?")==true){
document.getElementById("txt").removeAttribute("style"); ? ?
} ? ?
}
2017-04-25
換個(gè)方法名,比如widtha()