找不到錯誤呀,求幫忙
?<form>
? <!--當點擊相應按鈕,執行相應操作,為按鈕添加相應事件-->
? ? <input type="button" onClick="chang1()" value="改變顏色" > ?
? ? <input type="button" onClick="chang2()" value="改變寬高" >
? ? <input type="button" onClick="chang3()" value="隱藏內容" >
? ? <input type="button" onClick="chang4()" value="顯示內容" >
? ? <input type="button" onClick="chang5()" value="取消設置" >
? </form>
? <script type="text/javascript">
? var mystr=document.getElementById("txt");
//定義"改變顏色"的函數
? function chang1(){
? ? ? mystr.style.color="red";
? ? ? mystr.style.backgroundColor="green";
? }
//定義"改變寬高"的函數
? function chang2(){
? ? ? mystr.style.wedth="100px";
? ? ? mystr.style.height="400px";
? }
//定義"隱藏內容"的函數
? ?function chang3(){
? ? ? ?mystr.style.display="none";
? ?}
//定義"顯示內容"的函數
? ?function chang4(){
? ? ? ?mystr.style.display="block";
? ?}
//定義"取消設置"的函數
? ?function chang5(){
? ? ? ?var mymassage=confirm("是否取消設置?");
? ? ? ?if(mymassage==true)
? ? ? ?{
? ? ? ? ? ? ?txt.removeAttribute("style");
? ?}
? </script>
2015-07-19
2015-07-19
找不到錯誤瞎試的,mystr.removeAttribute("style")這個我也試過了,也不對。。。。。