Load CSS files using jQuery
Author :
Virendra Dugar
Blog :jQuery By Example
Date: 7/11/2012 10:32:00 AM
Today I got into a situation where I need to load CSS file dynamically using jQuery. My code was working in all the browsers except IE. But after spending couple of minute I was able to make proper cross browser solution.
Here is a piece of code that will load CSS using jQuery.
$(document).ready(function(){
$("head").append("<link>");
var css = $("head").children(":last");
css.attr({
rel: "stylesheet",
type: "text/css",
href: "CSS/Demo.css"
});
});
Feel free to contact me for any help related to jQuery, I will gladly help you.