I'd like to change the css of a page. I see two ways of doing it :
Using the Jquery .css function to change every tag in the html.
example :
$("body").css("background : red")
Or disabling the current css stylesheet and enable a new one.
example:
function switch_style ( css_title )
{
// You may use this script on your site free of charge provided
// you do not remove this notice or the URL below. Script from
// http://www.thesitewizard.com/javascripts/change-style-sheets.shtml
var i, link_tag ;
for (i = 0, link_tag = document.getElementsByTagName("link") ;
i < link_tag.length ; i++ ) {
if ((link_tag[i].rel.indexOf( "stylesheet" ) != -1) &&
link_tag[i].title) {
link_tag[i].disabled = true ;
if (link_tag[i].title == css_title) {
link_tag[i].disabled = false ;
}
}
}
}
Which way is the more efficient ? Or maybe there is better ways ?
bodyan extra class and usingbody.class2in your CSS instead of using a second stylesheet.