<body>
<div id = "container1" >
<div id = "x1" />
<div id = "x2" />
<div id = "x3" />
</div>
<div id = "container2" >
<div id = "Y1" />
<div id = "Y2" />
<div id = "Y3" />
</div>
<div id = "container3" >
<div id = "Z1" />
<div id = "Z2" />
</div>
</body>
$('body div').each(function(i) {
if($(this).attr('id')!='container2') { //This is only for div container2 & not for elements inside it
console.log(i);
}
});
我不希望特定的div內的元素說container2的要填充如何才能做到這一點.. 在上面的代碼裏面填充container2的如何不填充給定的div裏面的內容
div的
填充數據意味着什麼?你想隱藏特定div的內容嗎?或者清空那個div的數據? – San 2012-03-16 06:24:32
可以有多種方式,在您的_if_條件中添加另一個檢查,以檢查內部div的父級是否不是container2。這不是測試:!'$(本).parent()ATTR( '身份證')='container2'' – Coder 2012-03-16 06:31:09
@聖:我其實排空DIV – user1184100 2012-03-16 06:48:13