最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

請(qǐng)大神幫忙看看哪里有問(wèn)題所有按鈕都沒(méi)反應(yīng)

? <form>

? <!--當(dāng)點(diǎn)擊相應(yīng)按鈕,執(zhí)行相應(yīng)操作,為按鈕添加相應(yīng)事件-->

? ? <input type="button" value="改變顏色" onclick="mycolor()"/> ?

? ? <input type="button" value="改變寬高" onclick="mysize()"/>

? ? <input type="button" value="隱藏內(nèi)容" onclick="mynone()"/>

? ? <input type="button" value="顯示內(nèi)容" onclick="myblock()"/>

? ? <input type="button" value="取消設(shè)置" onclick="mycancel()"/>

? </form>

? <script type="text/javascript">

? var mytxt=document.getElementById("txt");

//定義"改變顏色"的函數(shù)

? function mycolor()

? { mytxt.style.color="red";

? ? mytxt.style.backgroundColor="#ccc";

? }

//定義"改變寬高"的函數(shù)

? function mysize()

? { mytxt.style.width="300px";

? ? mytxt.style.height="300px";

? }

//定義"隱藏內(nèi)容"的函數(shù)

? function mynone()

? { mytxt.style.display="none";

? }

//定義"顯示內(nèi)容"的函數(shù)

? function myblock()

? { mytxt.style.display="block";

? }

//定義"取消設(shè)置"的函數(shù)

? function mycancel()

? { var cel=confirm("是否取消所有設(shè)置");

? ? if(cel==true)

? ? { mytxt.style="""";//或者 mytxt.removeAttribute("style");

? ? }

? }

? </script>


正在回答

3 回答

//定義"取消設(shè)置"的函數(shù)

? function mycancel()

? { var cel=confirm("是否取消所有設(shè)置");

? ? if(cel==true)

? ? { mytxt.style="""";//或者 mytxt.removeAttribute("style");

? ? }

? }

在這段代碼中有兩處錯(cuò)誤:

1、?{ var cel=confirm("是否取消所有設(shè)置");

這一行當(dāng)中的“分號(hào)”用成了中文格式,這個(gè)錯(cuò)誤是我放在代碼編輯器中發(fā)現(xiàn)的;

2、?{ mytxt.style="""";//或者 mytxt.removeAttribute("style");?}

這一行代碼當(dāng)中mytxt.style = """";是語(yǔ)法錯(cuò)誤,

谷歌瀏覽器中給出了以下報(bào)錯(cuò)提示:

http://img1.sycdn.imooc.com//577a75420001e6e303290051.jpg

正確的書(shū)寫(xiě)方式應(yīng)該是mytxt.style = "";

可以試一下谷歌瀏覽器的console功能

2 回復(fù) 有任何疑惑可以回復(fù)我~
#1

夏天冷空氣 提問(wèn)者

謝謝,你好細(xì)心以后一定能成大牛
2016-07-04 回復(fù) 有任何疑惑可以回復(fù)我~
#2

etkiller

var mytxt=document.getElementById("txt"); 這一句是可以只用寫(xiě)一次的嗎?
2016-07-04 回復(fù) 有任何疑惑可以回復(fù)我~
#3

zuoxiaozuo 回復(fù) etkiller

這個(gè)和全局變量與局部變量有關(guān),任何在function外的聲明的變量都是一個(gè)全局的變量,你可以把它用在頁(yè)面的任何地方;假如你在某個(gè)function中聲明某個(gè)變量,那么這個(gè)變量只能在這個(gè)函數(shù)中訪問(wèn)。所以,在函數(shù)外聲明的變量mytxt是個(gè)全局變量,只需要聲明一次就可以了
2016-07-05 回復(fù) 有任何疑惑可以回復(fù)我~

你的是mytxt嗎?

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

夏天冷空氣 提問(wèn)者

對(duì)呀我看跟你的結(jié)構(gòu)一樣呀
2016-07-04 回復(fù) 有任何疑惑可以回復(fù)我~

function gbys(){
??? txt.style.color="#eee";
??? txt.style.backgroundColor="#f9c";
}
//定義"改變寬高"的函數(shù)
function gbkg(){
??? txt.style.width="300px";
??? txt.style.height="500px"; ?
}

//定義"隱藏內(nèi)容"的函數(shù)
function ycnr(){
??? txt.style.display='none';
}

//定義"顯示內(nèi)容"的函數(shù)
function xsnr(){
??? txt.style.display='block';
}

//定義"取消設(shè)置"的函數(shù)
function qxsz(){
? var qxss= confirm('是否取消設(shè)置?');
? if (qxss==true) {
???? txt.removeAttribute("style");
?? }
}

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

請(qǐng)大神幫忙看看哪里有問(wèn)題所有按鈕都沒(méi)反應(yīng)

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)