為什么運(yùn)行不了??
<!--當(dāng)點(diǎn)擊相應(yīng)按鈕,執(zhí)行相應(yīng)操作,為按鈕添加相應(yīng)事件-->
? ? <input type="button" value="改變顏色"? onclick="changecolor()"/>
? ? <input type="button" value="改變寬高"? onclick="changewh()">
? ? <input type="button" value="隱藏內(nèi)容"? onclick="yincang()">
? ? <input type="button" value="顯示內(nèi)容"? onclick="xianshi()">
? ? <input type="button" value="取消設(shè)置" onclick="changeqx()">
? </form>
? <script type="text/javascript">
? var mychar=document.getElementById("txt")
//定義"改變顏色"的函數(shù)
function changecolor{
? mychar.style.color="red"
? ?mychar.style.backgroundcoloe="black"
}
//定義"改變寬高"的函數(shù)
function changewh{
? ? mychar.style.width="100px"
? ? mychar.style.height="100px"
}
//定義"隱藏內(nèi)容"的函數(shù)
function yincang{
? ? mychar.style.display="none";
}
//定義"顯示的函數(shù)
function xianshi
? ? mychar.style.display="block";
}
//定義"取消設(shè)置"的函數(shù)
function changeqx(){
? ? var re=confirm("是否取消設(shè)置");
? ? if(re==true)
? ? {
? ? ? re.style="none";
? ? }
}
? </script>
</body>
</html>
2018-10-29
你定義的函數(shù)名后面沒有括號(hào):function changewh(){ .... }
2018-10-25
你沒有獲取屬性吧 你這樣賦值程序不認(rèn)識(shí)MYCHAR是啥啊