0
我想让文档之外的显示功能准备就绪。如果时间等于零,它必须向我证明正确与错误。但我得到一个错误**遗漏的类型错误:无法读取的未定义的属性“的indexOf” **Uncaught TypeError:无法读取未定义的属性'indexOf'
$(document).ready(function() {
droppableId = $(this)[0].id;
draggableId = ui.draggable[0].id;
var show = function(ui, droppableId, draggableId) {
if (wordMap[droppableId].indexOf(draggableId) != -1) {
ui.draggable.removeClass("ui-state-right").addClass("ui-state-right");
} else {
ui.draggable.removeClass("ui-state-right").addClass("ui-state-wrong");
}
}
});
var seconds = 60;
function secondPassed() {
var minutes = Math.round((seconds - 30)/60),
remainingSeconds = seconds % 60;
if (remainingSeconds < 10) {
remainingSeconds = "0" + remainingSeconds;
}
document.getElementById('countdown').innerHTML = minutes + ":" + remainingSeconds;
if (seconds == 00) {
clearInterval(countdownTimer);
document.getElementById('countdown').innerHTML = "0:00";
if (corrects >= 4) {
$("#successAlert").show();
$("#startAgainGameBtn").show();
} else {
$("#resultBtn").prop('disabled', true);
show();
$("#getSol").show();
}
} else {
seconds--;
}
}
var countdownTimer = setInterval('secondPassed()', 1000);
你可以显示你的HTML吗? –
尝试使'show()'窗口变量,所以它会'window.show = function(){}'然后你会使用window.show引用它 – Deckerz
错误的原因是'wordMap [droppableId]'做不提及任何东西。你期待它成为什么? –