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

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

哪里錯(cuò)了?

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>confirm</title>

? ? ?

? <script type="text/javascript">

? function rec(){? ? //函數(shù)

? ? var mymessage=confirm("你是男士?");//變量加上消息對(duì)話框

? ? if(mymessage==true)? //if和else是判斷語句

? ? {

? ? document.write("你是女士!");

? ? }

? ? else

? ??

? ? ? ? document.write("你是男士!");

? ? }

? ? </script>

? ?

? ?<script type="text/javascript">

? ? ? ?function asd()

? ? ? ? ? ?var ddd=confirm("你喜歡周杰倫嗎")

? ? ? ?if(asd==true){

? ? ? ? ? document.write("喜歡,他的歌超級(jí)好聽")

? ? ? ? ?};

? ? ? ? else

? ? ? ? ? ? {document.write("不喜歡,你沒有品味");

? ? ? ? }?

? ? ? ?

? ? ? </script>

? ?

? ?

? ?

</head>

<body>

? ? <input meme="button" type="button" onClick="rec()" value="點(diǎn)擊我,彈出確認(rèn)對(duì)話框" />

? ? <input name="buttom" type="bottom" onClick="asd()" value="點(diǎn)喜歡,點(diǎn)喜歡"/>

</body>

</html>


正在回答

2 回答

其實(shí)你把你現(xiàn)在的代碼復(fù)制到VScode里面,問題就顯而易見了!

第一:

http://img1.sycdn.imooc.com//625ecd460001634b04880267.jpg

創(chuàng)建函數(shù)的時(shí)候要有大括號(hào)!大括號(hào)!大括號(hào)!這個(gè)很重要!

再把后面的內(nèi)容放進(jìn)打括號(hào)里面,這個(gè)意思就是:當(dāng)點(diǎn)擊按鈕時(shí),執(zhí)行asd()里面的代碼,不點(diǎn)擊就不執(zhí)行!

第二:

http://img1.sycdn.imooc.com//625eca170001df1b04140278.jpg

if else條件語句不需要分號(hào),接著后面寫即可;

第三:

http://img1.sycdn.imooc.com//625eca830001388008250105.jpg

input元素的類型只有button,沒有bottom,按鈕的英語單詞是button哦(個(gè)人寫按鈕喜歡直接這樣寫->? ?<button>點(diǎn)擊我,彈出確認(rèn)對(duì)話框</button>)

第四:

http://img1.sycdn.imooc.com//625eceda0001f39d04220259.jpg

if語句里的條件時(shí)你創(chuàng)建的變量 bbb 是否為真 不是函數(shù)!所以這里應(yīng)該這樣寫 if (ddd == true) {...} else{...};

還有寫代碼的時(shí)候記得注意語句的邏輯哦!當(dāng)confirm類容為真時(shí),返回true,但是你看看根據(jù)你的意思是:你是女士?為真時(shí) 輸出 你是女士。


我個(gè)人比較喜歡把js寫在body之后:

<body>

? <input meme="button" type="button" onClick="rec()" value="點(diǎn)擊我,彈出確認(rèn)對(duì)話框" />

? <!-- <input name="buttom" type="bottom" onClick="asd()" value="點(diǎn)喜歡,點(diǎn)喜歡" /> -->

? <button onclick="asd()">點(diǎn)喜歡,點(diǎn)喜歡</button>

</body>


<script type="text/javascript">


? function rec() {

? ? var mymessage = confirm("你是男士?");//變量加上消息對(duì)話框

? ? if (mymessage == true) ?//if和else是判斷語句,當(dāng)mymessage為真時(shí)輸出

? ? {

? ? ? document.write("你是男士!");

? ? }

//否則輸出

? ? else {

? ? ? document.write("你是女士 ?!");

? ? };

? } ; //函數(shù)


</script>




<script type="text/javascript">


? function asd() {

? ? var ddd = confirm("你喜歡周杰倫嗎");

? ? if (ddd == true) {

? ? ? document.write("喜歡,他的歌超級(jí)好聽");

? ? }

? ? else {

? ? ? document.write("不喜歡,你沒有品味");

? ? }

? };

</script>


//其實(shí)這兩個(gè)函數(shù)可以寫在一個(gè)script標(biāo)簽里!


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

<html>


<head>

? ? <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

? ? <title>confirm</title>

? ? <script type="text/javascript">

? ? ? ? function rec() { ? ?//函數(shù)

? ? ? ? ? ? var mymessage = confirm("你是男士?");//變量加上消息對(duì)話框

? ? ? ? ? ? if (mymessage == true) ?//if和else是判斷語句

? ? ? ? ? ? //當(dāng) mymessage 為真,則頁面輸出你是男士

? ? ? ? ? ? {

? ? ? ? ? ? ? ? document.write("你是男士!");

? ? ? ? ? ? }

? ? ? ? ? ? //否則,則頁面輸出你是女士

? ? ? ? ? ? //輸出的順序錯(cuò)了

? ? ? ? ? ? else {

? ? ? ? ? ? ? ? document.write("你是女士!");

? ? ? ? ? ? }

? ? ? ? }


? ? ? ? function asd() {

? ? ? ? ? ? var ddd = confirm("你喜歡周杰倫嗎")

? ? ? ? ? ? // if中判斷條件應(yīng)該用變量而不是方法

? ? ? ? ? ? if (ddd == true) {

? ? ? ? ? ? ? ? document.write("喜歡,他的歌超級(jí)好聽")

? ? ? ? ? ? }

? ? ? ? ? ? else {

? ? ? ? ? ? ? ? document.write("不喜歡,你沒有品味");

? ? ? ? ? ? }

? ? ? ? }

? ? </script>

</head>

<body>

? ? <input meme="button" type="button" onClick="rec()" value="點(diǎn)擊我,彈出確認(rèn)對(duì)話框" />

? ? <!-- input的type沒有buttom, type值應(yīng)為button -->

? ? <input name="button" type="button" onClick="asd()" value="點(diǎn)喜歡,點(diǎn)喜歡" />

</body>

</html>


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

舉報(bào)

0/150
提交
取消
JavaScript入門篇
  • 參與學(xué)習(xí)       741063    人
  • 解答問題       9789    個(gè)

JavaScript做為一名Web工程師的必備技術(shù),本教程讓您快速入門

進(jìn)入課程

哪里錯(cuò)了?

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

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

幫助反饋 APP下載

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

公眾號(hào)

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