2017-03-11 7 views
1

「OKまたはキャンセルを押す」というメッセージが表示される未定義の確定ポップアップが表示され、段落が「あなたがクリックした」または「キャンセルしました」 "未定義で、段落を変更していないことを確認するポップアップを確認する

誰かがそれが起こっている理由と修正方法を説明できますか?多くのおかげで

@charset "UTF-8"; 
 
/* CSS Document */ 
 

 
body{ 
 
\t height:1000px; 
 
\t width:100%; 
 
\t background:#fff; 
 
\t margin:0; 
 
} 
 

 
.divider{ 
 
\t width:100%; 
 
\t height:auto; 
 
\t background:#CCC; 
 
\t display:block; 
 
\t margin:10px; 
 
} 
 

 
h2{ 
 
\t font-size:16px; 
 
\t display:block; 
 
} 
 
#confirm-paragraph{} 
 
#global-variable-paragraph{} 
 
#user-input{} 
 
#expressions{} 
 
#elephant-paragraph{} 
 
#method-1{} 
 
#method-2{} 
 
#ml{} 
 
#litres{} 
 
#conditional-operator{} 
 
#cast-1{} 
 
#cast-2{}
<!-- Checklist: Confirm Example --> 
 
<!-- Checklist: Local Variables --> 
 
<section class="divider"> 
 
<h2>Confirm Example</h2> 
 
<button onclick="confirm()">Click Me</button> 
 
<p id="confirm-paragraph">This text should change after clicking the button.</p> 
 
<p style="color:red; font-weight:bold">NOT WORKING Version 1!!!!!!!!</p> 
 
<p>Undefined should instead say "Press OK or Cancel".</p> 
 
<p>And text should change to either "you clicked ok" or "you clicked cancel"</p> 
 
<script> 
 
function confirmFunction() { 
 
\t var textentry; 
 
\t var confirmation = confirm('Press OK or Cancel'); 
 
\t if (confirmation == true) { 
 
\t \t textentry = "You clicked OK"; 
 
\t } else { 
 
\t \t textentry = "You clicked Cancel"; 
 
\t } 
 
\t document.getElementById("confirm-paragraph").innerHTML = textentry; 
 
} 
 
</script> 
 
</section>

答えて

2

あなたのクリックは、間違った関数を参照:

<button onclick="confirm()">Click Me</button> 

<button onclick="confirmFunction()">Click Me</button> 
する必要があります
関連する問題