blog.craiga.id.au — jQuery.getStylesheet

Just a quick brain dump which may be useful to someone searching for the same thing I was. Enjoy.

function getStylesheet(url, callback) {
   jQuery.get(url, function(data, status) {
        if(status == "success") {
            jQuery("head").append(
                    "<style type=\"text/css\">" +
                    data + "</style>");
        }
        callback(data, status);
    });
};

Published: Friday, 16th October 2009 at 2:39 PM

Related

About Craig Anderson

By day, he works for ABC TV as a web dev­el­oper. By night, he plays bass gui­tar in Look Who's Tox­ic. He also runs a little Unix Time­stamp con­ver­sion site. There are plen­ty of other things he should be doing, but most of the time he's dreaming of what he'll do when he grows up while watching bad Star Trek spin-offs.