Skip to content

Instantly share code, notes, and snippets.

@isGabe
Created November 25, 2013 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isGabe/7648256 to your computer and use it in GitHub Desktop.
Save isGabe/7648256 to your computer and use it in GitHub Desktop.
A Pen by Gabriel Luethje.
<p>Nothing to see here...</p>
<div class="one"></div>
<p>Just testing out writing some styles to <code>&lt;head&gt;</code> with jQuery. </p>
<p>Because unfortunately sometimes we have to do that.</p>
$('<style type="text/css">'+
'body{'+
'background:cornflowerblue;'+
'text-align:center;'+
'}'+
'.one{'+
'width:100px;'+
'height:100px;'+
'margin:20px auto;'+
'background:goldenrod;'+
'padding:10px;'+
'text-align:center;'+
'}'+
'</style>').appendTo($('head'));

Styles upside the head with jQuery

Yes, it's dirty, but sometimes we have to do it.

For example I'm working on a 3rd party search tool that for some odd reason allows a single custom javascript file, but no other customizations outside of their UI.

A Pen by Gabriel Luethje on CodePen.

License.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment