由于未捕获的参考错误,卡未翻转

Card not flipping due to uncaught reference error

我有一张卡片,一面显示一个内容,翻转时显示不同的内容。翻转是通过对 a 标记的 onClick 调用触发的。但是,我遇到了 flip 的未捕获引用错误。我应该采取什么步骤来调试它?我已经仔细检查了 html 和 JS 的语法(一切似乎都很好)。

HTML

p.footer: #[a(href='#', onclick='flip()') About #[span]]

JS

$(document).ready(function () {

  // FLIP IT

  function flip () {
    $('.card').toggleClass('about');
  }

});

错误

Uncaught ReferenceError: flip is not defined
 onclick @ (index):1

flip()$(document).ready 本地的,您无法使用 onclick='flip()'.

访问

最好使用jquery分配ready()中的处理程序。

$('p.footer a:contains(About)').click(flip);