How to link to a CSS if a certain condition happens?

I have two CSS pages,

I want to link the HTML page to one of them depending on certain conditions.

How to do it?

Answers


You can dynamically create the <link> element with JavaScript:

var link = document.createElement('link');

link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'css1.css';

document.head.appendChild(link);

Or just edit the href attribute of an existing one:

document.getElementById('your_stylesheet').href = 'css1.css';

And give your <link> element an id:

<link href="default.css" rel="stylesheet" type="text/css" id="your_stylesheet" />

Need Your Help

Generate and download excel file

java excel download

I have a list data in my spring mvc application. I need to generate excel file from this list and then send excel file to browser for download. Which library should I use and how can I use it?

Cant resolve requirements to install set of packages in Zend 2 Framework

php zend-framework2 composer-php

I have cloned my fork of Zend 2 from github because i wanted to do some tests after i found potential bug, problem is that i cant run tests because Bootstrap cant find autoload.php in vendor folder...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.