zl程序教程

您现在的位置是:首页 >  后端

当前栏目

js 元素Dom新建并插入页面createElement

JS 页面 元素 插入 dom 新建
2023-09-11 14:16:39 时间

纯js

var o = document.createElement('script');
o.type = 'text/template';
o.id = 'demo';
document.documentElement.childNodes[0].appendChild(o);

jquery

$("<script type='text/template'>").attr('id', id + '_template').appendTo("body").load(url, function (tpl) {
  cb(tpl);
});