第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

我自己在sublime中手寫(xiě)代碼,對(duì)話框怎么就是彈跳不出來(lái)了?

<!DOCTYPE?html>
<html>
<head>
<meta?charset="UTF-8">
<title>confirm確認(rèn)對(duì)話框</title>
<script>
function?rec(){
var?mymessage=confirm("你是女生嗎?");
if(mymessage==true){
document.write("你是女生!");
}
else{
document.write("你是男生!");
}
}
</script>
</head>
<body>
<input?name="button"?type="button"??onClick="rec()"?value="點(diǎn)擊我,彈出確認(rèn)對(duì)話框">
</body>
</html>


正在回答

5 回答

注意代碼中的分號(hào),要用英文的,你用的中文的。改了就可以了。

var?mymessage=confirm("你是女生嗎?");

if(mymessage==true){

document.write("你是女生!");

}

else{

document.write("你是男生!");

}



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

夜幕客船 提問(wèn)者

非常感謝!
2017-07-12 回復(fù) 有任何疑惑可以回復(fù)我~

請(qǐng)注意調(diào)用函數(shù)的方法,沒(méi)加括號(hào),還有id屬性記得加引號(hào):<input type="button" value="點(diǎn)我變紅" onclick='toRed()' >

<input type="button" value="點(diǎn)我變綠" onclick='toGreen()'>

<input type="button" value="點(diǎn)我變黃" onclick='toYellow()'>

<div id="cont"></div>


0 回復(fù) 有任何疑惑可以回復(fù)我~
<!DOCTYPE?html>
<html>
<head>
<meta?charset="UTF-8">
<title>函數(shù)傳參</title>
<style>
#cont{
width:300px;
height:300px;
background:gray;
}
</style>
<script>
function?toRed()
{
var?contid=document.getElementById('cont');
contid.style.background='red';
}
function?toGreen()
{
var?contid=document.getElementById('cont');
contid.style.background='green';
}
function?toYellow()
{
var?contid=document.getElementById('cont');
contid.style.background='yellow';
}
</script>
</head>
<body>
<input?type="button"?value="點(diǎn)我變紅"?onclick='toRed'?>
<input?type="button"?value="點(diǎn)我變綠"?onclick='toGreen'>
<input?type="button"?value="點(diǎn)我變黃"?onclick='toYellow'>
<div?id=cont></div>
</body>
</html>


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

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>函數(shù)傳參</title>

<style>

#cont{

width:300px;

height:300px;

background:gray;

}

</style>

<script>

function toRed()

{

var contid=document.getElementById('cont');

contid.style.background='red';

}

function toGreen()

{

var contid=document.getElementById('cont');

contid.style.background='green';

}

function toYellow()

{

var contid=document.getElementById('cont');

contid.style.background='yellow';

}

</script>

</head>

<body>

<input type="button" value="點(diǎn)我變紅" onclick='toRed' >

<input type="button" value="點(diǎn)我變綠" onclick='toGreen'>

<input type="button" value="點(diǎn)我變黃" onclick='toYellow'>

<div id=cont></div>

</body>

</html>


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

真厲害!怎么看出來(lái)的?差別真的好小,中文的分號(hào)要細(xì)小點(diǎn),英文的分號(hào)更加粗大一點(diǎn);但是我在書(shū)上看的說(shuō)分號(hào)不是必須,但是一種良好的編寫(xiě)習(xí)慣建議加上;但沒(méi)想到,寫(xiě)錯(cuò)分號(hào)影響這么大,直接導(dǎo)致效果顯示不出來(lái)!

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

肖瀟筱蕭3402552

這個(gè)書(shū)寫(xiě)代碼的時(shí)候就要細(xì)心了,輸入法注意下,你在代碼出錯(cuò)的時(shí)候可以檢查下出錯(cuò)信息,會(huì)有提示的
2017-07-13 回復(fù) 有任何疑惑可以回復(fù)我~
#2

夜幕客船 提問(wèn)者 回復(fù) 肖瀟筱蕭3402552

恩 我用的是sublime書(shū)寫(xiě),但是不知道怎么設(shè)置代碼錯(cuò)誤自動(dòng)提示?你重新打開(kāi)這個(gè)提問(wèn),我在下面的答案中新寫(xiě)了一串代碼,中英文輸入也注意了,可就是不顯示?親 幫忙看看!
2017-07-13 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

我自己在sublime中手寫(xiě)代碼,對(duì)話框怎么就是彈跳不出來(lái)了?

我要回答 關(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)