How-to add some content into the balise HEAD with jquery?
I'd like to insert dynamiccaly some balises of HTML in the head of the web document. I've tried to add :
开发者_如何学JAVA$("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>");
But it looks like it doesn't work...
Do you know if it's possible to add dynamiccaly some content in the head balise?
Thank you very much,
Bat
I think your problem might be that you are missing the url()
bit around your import url. You also do not need the quotes around the url. See this reference: http://htmlhelp.com/reference/css/style-html.html#importing
Try changing it to:
$("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>');
精彩评论