我正在创建记忆游戏。我想翻转卡片(Div),让它更逼真。对于翻转,我使用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);
}
}
}谁能告诉我为什么会出现这个错误,以及如何修复它
发布于 2014-06-23 06:54:52
您缺少设置对象:
$("#" + id + " img").flip({direction: 'lr'});您可以在plugin page中获得一些示例。
https://stackoverflow.com/questions/24356442
复制相似问题