【发布时间】:2011-07-08 09:11:02
【问题描述】:
我想使用 jQuery 为文档异步加载 CSS。
我找到了这个示例,但这似乎在 IE 中不起作用:
<script type="text/javascript" src="/inc/body/jquery/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript">
$(function(){
$('<link>', {
rel: 'stylesheet',
type: 'text/css',
href: '/inc/body/jquery/css/start/jquery-ui-1.8.10.custom.css'
}).appendTo('head');
$.getScript("/inc/body/jquery/js/jquery-ui-1.8.10.custom.min.js", function(){
});
});
</script>
基本上我想在所有其他数据、图像、样式等加载到页面后加载jQuery UI。
$.getScript 非常适合 JS 文件。唯一的问题是 IE 中的 CSS。
你知道更好的解决方案吗?
【问题讨论】:
-
如果你把它做成
$('<link/>'...,它会起作用吗? IE。添加正斜杠。 -
我不确定您所说的异步是什么意思...您可能是指动态的吗?
标签: jquery css jquery-ui asynchronous