在jquery中加载外部css文件,如脚本,在jquery中也兼容 [英] Load external css file like scripts in jquery which is compatible in ie also
本文介绍了在jquery中加载外部css文件,如脚本,在jquery中也兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有一种加载外部CSS文件的方法,例如我们使用.getScript方法加载JS文件,还可以使用.getScript中的回调函数
Is there a way to load external CSS files, like we load JS file by using .getScript method and also use the callback function like in .getScript
$("<link/>", {
rel: "stylesheet",
type: "text/css",
href: "/styles/yourcss.css"
}).appendTo("head");
这在FireFox和类似版本中有效,但在IE中无效.
This Works in FireFox and similar but not in IE.
推荐答案
在jQuery 1.4中:
In jQuery 1.4:
$("<link/>", {
rel: "stylesheet",
type: "text/css",
href: "/styles/yourcss.css"
}).appendTo("head");
http://api.jquery.com/jQuery/#jQuery2
这篇关于在jquery中加载外部css文件,如脚本,在jquery中也兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文