亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

函數取名src可以嗎,代碼應該對的,但試了好幾次居然通不過

隨意取的函數名,好幾次通不過,點擊取消設置沒反應,,,吧src換個名字通過了。換sr就通過了。。折騰了大半夜。這尼瑪是怎么回事???雖然有點鉆牛角尖

?<form>

? <!--當點擊相應按鈕,執行相應操作,為按鈕添加相應事件-->

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

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

? ? <input type="button" onclick="hidetxt()" value="隱藏內容" >

? ? <input type="button" onclick="showtxt()" value="顯示內容">

? ? <input type="button" onclick="src()" value="取消設置" >

? </form>

? <script type="text/javascript">

//定義"改變顏色"的函數

var char=document.getElementById("txt");

function changecolor()

{char.style.color="red";

char.style.backgroundColor="#ccc";}


//定義"改變寬高"的函數

function changewh()

{char.style.width="300px";

char.style.height="300px";}


//定義"隱藏內容"的函數

function hidetxt(){

? ? char.style.display="none";}


//定義"顯示內容"的函數

function showtxt(){

? ? char.style.display="block";}


//定義"取消設置"的函數

?function src(){

? ? var message=confirm("你確定要重置所有設置么?");

? ? if(message==true)

? ? {? ? ??

? ? ? ? ?char.removeAttribute('style');

? ? }?

? } ? ?

? </script>

</body>

</html>


正在回答

1 回答

src是JS中的關鍵字,在JS中命名變量或者函數的時候,禁止使用JS中的關鍵字來命名

0 回復 有任何疑惑可以回復我~
#1

Nemonameless 提問者

非常感謝!
2015-02-11 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

函數取名src可以嗎,代碼應該對的,但試了好幾次居然通不過

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號