我正在创造记忆游戏。我想翻转卡片(div)以使其更逼真。对于fliping我正在使用THIS插件。问题是卡片翻转不起作用。我从控制台收到此错误:
Uncaught TypeError: Cannot read property 'direction' of undefined
您可以在此处查看我的代码:JSFIDDLE
编辑1:
完整错误日志:
Uncaught TypeError: Cannot read property 'direction' of undefined VM24:1
(anonymous function) VM24:1
m.extend.each jquery.min.js:2
m.fn.m.each jquery.min.js:2
$.fn.flip VM24:1
OpenCard mem.js:94
m.event.dispatch jquery.min.js:3
r.handle
此函数使用包含Jquery Flip插件的flip()函数:
function OpenCard() {
var id = $(this).attr("id");
if ($("#" + id + " img").is(":hidden")) {
$(Source + " div").unbind("click", OpenCard);
$("#" + id + " img").flip();
if (ImgOpened == "") {
BoxOpened = id;
ImgOpened = $("#" + id + " img").attr("src");
setTimeout(function() {
$(Source + " div").bind("click", OpenCard)
}, 300);
} else {
CurrentOpened = $("#" + id + " img").attr("src");
if (ImgOpened != CurrentOpened) {
setTimeout(function() {
$("#" + id + " img").flip();
$("#" + BoxOpened + " img").flip();
BoxOpened = "";
ImgOpened = "";
}, 400);
Counter-=10;
wrong.play();
} else {
$("#" + id + " img").parent().css("disabled", "disabled");
$("#" + BoxOpened + " img").parent().css("disabled", "disabled");
ImgFound++;
BoxOpened = "";
ImgOpened = "";
Counter+=100;
correct.play();
}
setTimeout(function() {
$(Source + " div").bind("click", OpenCard)
}, 400);
}
$("#counter").html("" + Counter);
if (ImgFound == ImgSource.length) {
clearInterval(timer);
alert ("Your score is "+Counter);
}
}
}
有人可以告诉我为什么我会收到此错误以及如何解决此问题