I have the following HTML:原型隱藏具有特定鏈路(<a href)
<div> <a href="http://google.com"> Google </a></div>
I am using prototype library. I need to hide the div that has the link http://google.com用的div謝謝
I have the following HTML:原型隱藏具有特定鏈路(<a href)
<div> <a href="http://google.com"> Google </a></div>
I am using prototype library. I need to hide the div that has the link http://google.com用的div謝謝
在原型:
$$('div a[href="http://google.com"]').each(function (e) { Element.hide(e.parentNode); })
你可以使用CSS來做到這一點
<div class="hideMe"> <a href="http://google.com"> Google </a></div>
,然後在CSS做:。
#hideMe {
display:none;
}
是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
秒。