qq_8e8e游戲商務(wù)_0
2017-03-24 14:16:22
?<input type="button" value="改變顏色" onclick="changecolor()"> ?? ? <input type="button" value="改變寬高" onclick="changeshape()">? ? <input type="button" value="隱藏內(nèi)容" onclick="hide()">? ? <input type="button" value="顯示內(nèi)容" onclick="block()" >? ? <input type="button" value="取消設(shè)置" onclick="rec()" >? </form>? <script type="text/javascript">//定義"改變顏色"的函數(shù)function changecolor(){var chc=document.getElementById("con");?? ?chc.style.color="red";? ?var chc1=document.getElementById("txt");? ?chc1.style.backgroundColor="blue";}//定義"改變寬高"的函數(shù)function changeshape(){var chc=document.getElementById("txt");? chc.style.width:30px;? chc.style.height:20px;}//定義"隱藏內(nèi)容"的函數(shù)? function hide()? {var mychar = document.getElementById("txt");? ? ? mychar.style.display="none";}//定義"顯示內(nèi)容"的函數(shù)function block(){ var mychar = document.getElementById("txt");? ? ? mychar.style.display="block";}//定義"取消設(shè)置"的函數(shù)function rec(){var a=confirm("是否取消!");? ?if(a)? ? var mychar=document.getElementById("txt");? ? mychar.removeAttribute("style");}
2 回答


學(xué)習(xí)js
TA貢獻85條經(jīng)驗 獲得超55個贊
你的取消設(shè)置的if語句也有問題,
function rec() {
?? ??? ??? ??? ?var a = confirm("是否取消!");
?? ??? ??? ??? ?if(a==true){
?? ??? ??? ??? ??? ?var mychar = document.getElementById("txt");
?? ??? ??? ??? ?mychar.removeAttribute("style");
?? ??? ??? ??? ?}
?? ??? ??? ?}
改成這樣就可以了
點擊展開后面1條
添加回答
舉報
0/150
提交
取消