2013-06-12 30 views
0

我正在使用這個CSS。但是,隨着IE7和IE8不支持nth child所以我想用jQuery做它,所以它在所有的瀏覽器如何將css解釋爲jQuery?

#localFileCopyingDiv, #supplementaryMaterialsDiv, #assetsDiv, table tr td:nth-child(1 /*this is the column number*/){ 
    text-align: center; 
    width:30px 
} 

#localFileCopyingDiv, #supplementaryMaterialsDiv, #assetsDiv, table tr td:nth-child(2 /*this is the column number*/){ 
    width:250px 
} 

#localFileCopyingDiv, #supplementaryMaterialsDiv, #assetsDiv, table tr td:nth-child(3 /*this is the column number*/){ 
    width:250px 
} 

#localFileCopyingDiv, #supplementaryMaterialsDiv, #assetsDiv, table tr td:nth-child(4 /*this is the column number*/){ 
    width:60px 
} 

#localFileCopyingDiv #supplementaryMaterialsDiv, #assetsDiv table tr td:nth-child(5 /*this is the column number*/){ 
    width:220px 
} 

#courseInfoDiv table tr td:nth-child(1 /*this is the column number*/){ 
    width: 200px; 
} 

#courseInfoDiv table tr td:nth-child(2 /*this is the column number*/){ 
    width: 600px; 
} 

我如何轉換上面提到的CSS到jQuery的工作嗎?

感謝

編輯: ----------------------------------- ---------

<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
    <title>Status Report</title> 

    <script type="text/javascript" src="javascript/jquery-1.9.1.min.js"></script> 
    <!--[if (gte IE 6)&(lte IE 8)]> 
     <script type="text/javascript" src="javascript/selectivizr-min.js"></script> 
     <noscript><link rel="stylesheet" href="brands/default/en/css/exportComplete.css" /></noscript> 
    <![endif]--> 
    <script type="text/javascript" src="javascript/jquery-migrate-1.2.1.js"></script> 
    <link rel="stylesheet" type="text/css" href="brands/default/en/css/exportComplete.css" /> 
</head> 

可以嗎?

+0

您是否動態添加了一些受css規則影響的內容? –

+0

你可以考慮這個解決方案: http://stackoverflow.com/questions/8492121/ie8-nth-child-and-before – AllWorkNoPlay

+0

www.jquery.com閱讀文檔。 –

回答

2

一種選擇是使用插件如Selectivizr得到:nth-child選擇器(各種其它僞/屬性選擇器之間)的舊版本的IE運作。

「Selectivizr是一個JavaScript實用程序,它模擬CSS3僞類 和Internet Explorer 6-8中的屬性選擇器。」

正如你已經在使用JavaScript庫(jQuery的),所有你需要做的是包括Selectivizr <script><head>瞧。

Here's a tutorial在這裏你可以看到一個簡單的使用例子,以及它在封面下如何工作的解釋。

+0

是的,我包括jquery到我的HTML像'' – Basit

+0

檢查我的編輯,可以嗎?就是這樣或者我需要用我的CSS做些什麼? – Basit

+0

@Basit您需要將[fallback css]更改爲.css文件。我添加了一個鏈接,您可能會發現有用:) – lifetimes