不知道什么原因是失敗的,試驗人家的沒有問題啊
? <form>
? <!--當點擊相應按鈕,執行相應操作,為按鈕添加相應事件-->
??? <input type="button" value="改變顏色" onClick="1()"> ?
??? <input type="button" value="改變寬高" onClick="2()">
??? <input type="button" value="隱藏內容" onClick="3()">
??? <input type="button" value="顯示內容" onClick="4()">
??? <input type="button" value="取消設置" onClick="5()">
? </form>
? <script type="text/javascript">
??? var txt=document.getElementById("txt");
??????? function 1()
??????? {
??????????? txt.style.color="red";
??????????? txt.style.backgroundColor="#ccc";
??????? }
??????? function 2()
??????? {
??????????? txt.style.width="300px";
??????????? txt.style.height="300px";
??????? }
??????? function 3()
??????? {
??????????? txt.style.display="none";
??????? }
??????? function 4()
??????? {
??????????? txt.style.display="block";
??????? }
??????? function 5()
??????? {
??????????? var a=confirm();
??????????? if(a==true)
??????????? {
??????????????? txt.removeAttribute("style");
??????????? }
??????? }
? </script>
2016-04-05
字母或者下劃線開頭吧。。。。。--
2016-03-29
好吧,不能用數字做函數名稱