Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I made this plugin witch does what you want, if the stylesheet dosn't break the <a href="https://developer.mozilla.org/en-US/docs/Same_origin_policy_for_JavaScript" rel="nofollow">same origin policy</a>.</p> <p><strong>You can use it like this:</strong></p> <pre><code>&lt;link rel="stylesheet" href="..." data-wrapper="#mySelector" /&gt; &lt;style data-wrapper="#mySelector"&gt; .ninja { visibility: hidden; } &lt;/style&gt; </code></pre> <p><strong>And again after initialize:</strong></p> <pre><code>$("link[rel='stylesheet']").addWrapperToStyle("#mySelector"); $("style").addWrapperToStyle("#mySelector"); </code></pre> <hr> <pre><code> (function($) { var $styleSheet = $("&lt;style type='text/css'/&gt;").appendTo("head"); function getStyle( $element, callback ) { callback($element.text()); } function getLink( $element, callback ) { $.get($element.attr("href"), function( style ) { callback(style); }); } function appendStyle( style ) { $styleSheet.text(function(i, text) { return text + "\n" + style; }); } function wrapStyle( element, selector ) { var $element = $(element); if ( $element.is("style") ) { getStyle( $element, callback ); } else { getLink( $element, callback ); } function callback( style ) { if ( style ) { style = ("" + style).replace(/([^}]+){/g, function(match) { var matches = match.split(","), i = 0, len = matches.length; for ( ; i &lt; len; i++ ) { matches[i] = selector + " " + $.trim(matches[i]) } match = matches.join(","); return match; }); appendStyle(style); $element.remove(); } } } $(function() { $("link[rel='stylesheet'][data-wrapper], style[data-wrapper]").each(function() { wrapStyle( this, this.getAttribute("data-wrapper") ); }); }); $.fn.addWrapperToStyle = function( wrapper ) { return this.each(function() { wrapStyle(this, wrapper); }); } })(jQuery); </code></pre> <p><strong>Im not sure about cross browser compatibility. But you can try...</strong> </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload