我在我的 CSS 代码中使用了 nth-child
,但它在 IE 8 中不起作用。
我知道 IE 8 无法处理 nth-child
但我需要找到一种方法让它工作。
这是我的代码:
.paypalshop .shop-groups li:nth-child(1){
float:left;
border: 1px solid #ccc;
width:200px;
}
.paypalshop .shop-groups li:nth-child(2){
float:left;
border: 1px solid #ccc;
width:150px;
}
.paypalshop .shop-groups li:nth-child(3){
float:left;
border: 1px solid #ccc;
width:210px;
}
.paypalshop .shop-groups li:nth-child(4){
float:left;
border: 1px solid #ccc;
width:200px;
}
.paypalshop .shop-groups li:nth-child(5){
float:left;
border: 1px solid #ccc;
width:70px;
}
.paypalshop .shop-groups li:nth-child(6){
float:left;
border: 1px solid #ccc;
width:105px;
}
.paypalshop .shop-groups li:nth-child(7){
float:left;
border: 1px solid #ccc;
width:154px;
}
.paypalshop .shop-groups li:nth-child(8){
float:left;
border: 1px solid #ccc;
width:130px;
}
.paypalshop .shop-groups li:nth-child(9){
float:left;
border: 1px solid #ccc;
width:220px;
}
.paypalshop .shop-groups li:nth-child(10){
float:left;
border: 1px solid #ccc;
width:220px;
}
所以我需要找到一种方法让 nth-child
函数在 IE 8 上工作。是否有任何 jQuery 方法我可以用来让它在 IE 8 上工作?
谢谢!
最佳答案
是的,使用 :nth-child 选择器
http://api.jquery.com/nth-child-selector/
随着 css 的改变
例如
$("paypalshop .shop-groups li:nth-child(2)").css("width":"150px","float":"left","border":"1px solid #ccc");
关于javascript - 第 N 个 child 使用 Jquery 而不是 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11765722/