如何加载CSS使用jquery [英] How to load CSS using jquery
本文介绍了如何加载CSS使用jquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在服务器上加载了一个css文件,所以我有一个URL与我。如何使用JQuery将其加载到我的perl代码?
I have loaded a css file on server so I am having a URL with me. How can i load it in my perl code using JQuery ?
现在我正在硬编码css在我的mason页面,从页面中缺少这样
So currently I am hardcoding the css in my mason page which is missing from the page something like this
JQ.onReady('show', function(){
JQ.addStyles({styles: ["\n\n.ap_classic { border-top:1px solid #ccc;border-left:1px solid #ccc;border-bottom:1px solid #2F2F1D; border-right:1px solid #2F2F1D;background-color:#EFEDD4;padding:3px; } .ap_classic .ap_titlebar { color:#86875D;font-size:12px;padding:0 0 3px 0;line-height:1em; } .ap_classic .ap_close { float:right; } .ap_classic .ap_content { clear:both;background-color:white;border:1px solid #ACA976;padding:8px;font-size:11px; } "]});
});
我想避免硬编码此css?
I want to avoid hardcoding this css ?
推荐答案
我不明白为什么你不能只是插入< link />
c>< head /> 部分,但这里有一个jQuery片段:
I don't get why you can not just insert the <link/>
element in the <head/>
section, but here's a jQuery snippet:
$('head').append( $('<link rel="stylesheet" type="text/css" />').attr('href', 'your stylesheet url') );
这篇关于如何加载CSS使用jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文