為什么我設(shè)置寬高的按鈕不起作用?
? <!--當(dāng)點(diǎn)擊相應(yīng)按鈕,執(zhí)行相應(yīng)操作,為按鈕添加相應(yīng)事件-->
? ? <input type="button" value="改變顏色" ?onclick="color()"/> ?
? ? <input type="button" value="改變寬高" ?onclick="width()"/>
? ? <input type="button" value="隱藏內(nèi)容" ?onclick="none()"/>
? ? <input type="button" value="顯示內(nèi)容" ?onclick="block()"/>
? ? <input type="button" value="取消設(shè)置" >
? </form>
? <script type="text/javascript">
? var mychar=document.getElementById("txt");
//定義"改變顏色"的函數(shù)
function color(){
mychar.style.color="red";
}
//定義"改變寬高"的函數(shù)
function width(){
? ? mychar.style.width="600px";
? ? mychar.style.height="100px";
}
//定義"隱藏內(nèi)容"的函數(shù)
function none(){
? ? mychar.style.display="none";
}
//定義"顯示內(nèi)容"的函數(shù)
function block(){
? ? mychar.style.display="block";
}
//定義"取消設(shè)置"的函數(shù)
? </script>
2017-09-13
關(guān)鍵詞
2017-09-11
width是特有關(guān)鍵詞不能用這個(gè)的你改成chwidth就好了
2017-09-10
改變寬度要用function width()進(jìn)行設(shè)置 ?不能用width?
2017-09-10
"改變寬高"的函數(shù)不能使用 width 做為函數(shù)名!