2009-05-19 21 views

回答

3

在原型:

$$('div a[href="http://google.com"]').each(function (e) { Element.hide(e.parentNode); }) 
1

你可以使用CSS來做到這一點

<div class="hideMe"> <a href="http://google.com"> Google </a></div> 

,然後在CSS做:。

#hideMe { 
    display:none; 
} 
0

jQuery提供給您

如果是這樣,使用下面的代碼:

$(document).ready(function() { 
    $('a[href=http://www.google.com]').parent('div').hide(); 
}); 

如果父不一定在DOM緊跟其後的水平,使用替代.parents

$(document).ready(function() { 
    $('a[href=http://www.google.com]').parents('div').hide(); 
}); 

但是可能在樹一個更高的水平影響div秒。