如何根据var中输入的数据设置var以链接不同的样式表

时间:2014-02-17 11:57:41

标签: javascript jquery

我想基于我手动输入的var来拉出不同的样式表,我该怎么做?

varDivision = "" //SET TOTAL NUMBER OF DIVISIONS IN YOUR LEAGUE
varTeams = ""    //ENTER TOTAL NUMBER OF TEAMS IN YOUR LEAGUE 

if 1 division 5 teams link this stylesheet "url"
if 1 division 6 teams link this stylesheet "url"
if 2 divisions 10 teams link this stylesheet "url"
if 3 divisions 12 teams link this stylesheet "url"

等等。我可以列出每种可能性......

1 个答案:

答案 0 :(得分:0)

您可以在<link/>部分

中插入<head/>元素
$('head')
.find('*[data-dynamicCss="true"]').remove()
.append( $('<link rel="stylesheet" type="text/css" data-dynamicCss="true" />')
.attr('href', 'your stylesheet url') );