我正在創建這個很酷的HTML Jeopardy遊戲,我需要一點編碼幫助。 現在我只是在第一個問題上工作。這在FancyBox中彈出。爲什麼我的jQuery .click()回調沒有正確處理輸入?
我正在使用if來標識正確的答案,但它不起作用。
我的代碼:
$(document).ready(function() {
var tag_100_input = $('#tag_100_ans').val();
$('#tag_100_button').click(function() {
if (tag_100_input == 'strong' || tag_100_input == 'b' || tag_100_input == '<strong>' || tag_100_input == '<b>') {
$('.tag_100_correct').fadeIn(500);
setTimeout("$.fancybox.close()", 3000);
score += 100;
$('#tag_100_not').css('display', 'none');
$('#tag_100').css('display', 'none');
}
else {
$('.tag_100_wrong').fadeIn(500);
setTimeout("$.fancybox.close()", 3500);
$('#tag_100_not').css('display', 'none');
$('#tag_100').css('display', 'none');
}
$('.score').html(score);
});
});
的危險的問題是:什麼 標籤可以使文字加粗?
即使當我進入awnsers之一:b
,strong
,<b>
,或<strong>
這表明我錯了<span>
而不是正確的一個。這是爲什麼?
無關你的問題,你應該使用功能的setTimeout裏面......像這:'setTimeout(function(){$ .fancybox.close();},3500);' – Mottie