如何插入
其他提示
如果您要包含JavaScript入目,你可能会做这样的事情:
$$('head').first().insert({
bottom: new Element('script', {
type: 'text/javascript'
}).update('function helloWorldToConsole(){console.log("Hello World!")}')
});
这会创建一个新的脚本,并将其插入到头部的底部。但是,如果你添加一个外部JavaScript文件这样它会更漂亮:
$$('head').first().insert({
bottom: new Element('script', {
type: 'text/javascript',
src: 'http://www.example.com/path/file.js'
})
});
您可以用比你的脚本日后使用的功能。
尝试这个..
$('<script></script>',{
type:'custom',
id:'script1'
}).appendTo('head').attr('type','text/javascript');
$('#script1').append(< add js code here >);
});
不隶属于 StackOverflow