jQuery ajax load() javascript not executing?

后端 未结 8 1125
执念已碎
执念已碎 2020-11-29 07:49

I\'ve read several posts about this issue but i can\'t solve it.

I am loading an html file into a div. The file i am loading contains a unordered list. This list sho

8条回答
  •  甜味超标
    2020-11-29 08:18

    You can load javascript file dynamically with help of jQuery.getScript and set a callback function. When the script has been loaded the callback function called. Here's an example of loading highlightjs library from cdnjs:

    $.getScript("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/highlight.min.js", function () {
        $('pre code').each(function(i, block) {
            // hljs now is available
            hljs.highlightBlock(block);
        });
    });
    

提交回复
热议问题