Can't append [removed] element

后端 未结 18 2198
被撕碎了的回忆
被撕碎了的回忆 2020-11-21 06:11

Any idea why the piece of code below does not add the script element to the DOM?

var code = \"\";
$(\"#someElement\").append(cod         


        
18条回答
  •  盖世英雄少女心
    2020-11-21 06:48

    It is possible to dynamically load a JavaScript file using the jQuery function getScript

    $.getScript('http://www.whatever.com/shareprice/shareprice.js', function() {
      Display.sharePrice();
    });
    

    Now the external script will be called, and if it cannot be loaded it will gracefully degrade.

提交回复
热议问题