如何用jquery将一些内容添加到balise HEAD中?

时间:2010-12-13 16:45:27

标签: jquery dojo add head

我想在web文档的头部插入dynamiccaly的一些HTML应用程序。我试图添加:

$("head").append("<style type=\"text/css\"> @import \"http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojox/grid/resources/claroGrid.css\";.container { text-align: center; margin: 10px; } .info { margin: 10px; }</style>");

但看起来它不起作用......

你知道是否有可能在头部应用程序中添加dynamiccaly一些内容?

非常感谢,

蝙蝠

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)

我认为您的问题可能是您错过了导入网址周围的url()位。您也不需要网址周围的引号。请参阅此参考:http://htmlhelp.com/reference/css/style-html.html#importing

尝试将其更改为:

$("head").append('<style type="text/css"> @import url(http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojox/grid/resources/claroGrid.css); .container { text-align: center; margin: 10px; } .info { margin: 10px; }</style>');