[英]Including JavaScript and CSS in a page (jQuery)
I recently came across the includeMany jQuery plugin to include external JavaScript and CSS files into a page. 我最近遇到了includeMany jQuery插件,将外部JavaScript和CSS文件包含到页面中。 Although it was released in early 2009 there are NO references in blogs or elsewhere.
虽然它在2009年初发布,但在博客或其他地方没有引用。 I wonder if it's usable?
我想知道它是否可用? What is the experience using it?
使用它的经验是什么?
You can include JavaScript and CSS using the example below. 您可以使用以下示例包含JavaScript和CSS。 There is no need for any plugins.
不需要任何插件。
To include JavaScript code, do this: 要包含JavaScript代码,请执行以下操作:
$.getScript("youpathtoscript.js",function() {
//this script is loaded
});
To include CSS files: 要包含CSS文件:
$("<link/>", {
rel: "stylesheet",
type: "text/css",
href: "styles/yourcss.css"
}).appendTo("head");
For collection of CSS/JavaScript import (including): 用于CSS / JavaScript导入的收集(包括):
Eval alternative: Eval替代方案:
$("<script></script>", {type: "text/javascript",})
.text("alert('your function');")
.appendTo("head");
Embedded CSS: 嵌入式CSS:
$("<style></style>", {type: "text/css",})
.text("#you{css:rule}")
.appendTo("head");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.