私はちょうどコーディングを始めました。私はクイズを出しました。生徒が正しい答えをクリックすると音が鳴り、誤った答えをクリックすると別の音が鳴ります。私はいくつかの投稿をオンラインで見つけましたが、彼らは働いていません。誰も助けることができますか?前もって感謝します!javascriptでボタンをクリックしたときの音の追加
Javascriptを:
function checkAnswer(){
myAnswer=$('#inputBox').val();
if(myAnswer.slice(myAnswer.length-1,myAnswer.length)==" "){
myAnswer=myAnswer.slice(0,myAnswer.length-1);}
if(currentAnswer==myAnswer){
score++;
$('#feedback').append('<img src="tick.png">');
$('#inputBox').css("background-color","green");
$('#inputBox').css("color","white");
}
else{
$('#feedback').append('<img src="cross.png">');
$('#inputBox').css("background-color","red");
$('#inputBox').css("color","white");
$('#inputBox').val($('#inputBox').val()+" (ans= "+currentAnswer+")");
}
$('#message').append('Press ENTER again to continue');
$("#inputBox").prop('disabled', true);
$("#gameArea").focus();
gamePosition=2;
if(currentQuestionNumber==numberOfQuestions){gamePosition=3;}
}//checkAnswer
HTML:
<!DOCTYPE HTML>
<head>
<title>Quiz</title>
<meta name=viewport content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link href="main.css" rel="stylesheet" type="text/css"/>
<link href="mainclock.css"rel="stylesheet"type="text/css"/>
<script src="jquery.js"></script>
<script src="controller.js"></script>
</head>
<body>
<div id="gameArea" tabindex="1"></div>
<div id="mainStage">
</div>
</body>
HTML/JSファイルに 'audio'要素がありません。 – Rayon
['