Select Prototype隐藏具有特定链接的div(<;a href)

Select Prototype隐藏具有特定链接的div(<;a href),select,html,prototypejs,href,Select,Html,Prototypejs,Href,我有以下HTML: <div> <a href="http://google.com"> Google </a></div> 我正在使用原型库。我需要隐藏有链接的div。谢谢。您可以使用CSS来完成此操作 <div class="hideMe"> <a href="http://google.com"> Google </a></div> 您可以使用CSS来实现这一点 <div clas

我有以下HTML:

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


我正在使用原型库。我需要隐藏有链接的div。谢谢。

您可以使用CSS来完成此操作

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

您可以使用CSS来实现这一点

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

如果是,请使用以下代码:

$(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
s。

对您可用吗

如果是,请使用以下代码:

$(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();
});
但是,这可能会影响树中更高级别的divs。

在原型中:

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

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