动态加载JS 和 CSS

 

<script type="text/javascript">
$(function () {
var filename = '/assets/css/main.css';
var fileref = document.createElement("link");
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", filename);
document.getElementsByTagName("head")[0].appendChild(fileref);

 

var filescript = document.createElement("script");
filescript.type = "text/javascript";
filescript.src = "/assets/js/main.js";
document.getElementsByTagName('body')[0].appendChild(filescript);
});
</script>

posted @ 2016-05-15 13:27  毒逆天  阅读(753)  评论(0编辑  收藏  举报