ReferenceError:prettyPrint未定义错误

use*_*720 0 javascript google-code-prettify

希望你能帮助我ReferenceError: prettyPrint is not defined.

<a class="question helpcenterheading" href="http://www.google.com">How do I contact you?</a>
<span class="answer">One moment...</span>

<script>
$(document).ready(function() {
    $("span.answer").hide();
    $("a.question").click(function() {
        $(this).toggleClass("active").next().slideToggle(2000, function() {
            window.location.href = $(this).attr('href');
        });
        return false;
    });
});
</script>
Run Code Online (Sandbox Code Playgroud)

(现场版)

Bar*_*mar 6

根据文档,有两种方法可以运行Prettify:

1)自动加载器run_prettify.js.这不需要您调用任何函数,您可以在URL中指定一些参数.

2)通过加载prettify.css和提供自己的JS和CSS prettify.js.然后你需要使用<body onload="prettyPrint()">.

我想你正在使用自动加载器,然后试着打电话prettyPrint().选择一种或另一种方法,你不能混合它们.


eth*_*ous 5

你有

<body onload="prettyPrint()">
Run Code Online (Sandbox Code Playgroud)

但 PrettyPrint 从未被定义