Dynamic google-code-prettify doesn't work

后端 未结 1 1769
囚心锁ツ
囚心锁ツ 2020-12-03 15:39

Is it possible for a button to call a function that would \'prettify\' a dynamic

? I can\'t get it to work.

After the page loads,

相关标签:
1条回答
  • 2020-12-03 16:01

    Apparently after the code is prettified, an additional class is added which is prettyprinted. Anything with the class of prettyprinted is not re-prettified. You need to remove that class before recalling the function:

    $('input[type=button]').click( function() {
        $("#jsExample").text("    var user = 'private'; //Do NOT store your API Key on a script.")
            .parent().removeClass("prettyprinted");
    
       prettyPrint();
    });
    

    http://jsfiddle.net/uwBjD/3/

    0 讨论(0)
提交回复
热议问题