繁体   English   中英

Prototype隐藏具有特定链接的div(

[英]Prototype hide the div that has a specific link (<a href)

我有以下HTML:

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

我正在使用原型库。 我需要隐藏带有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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM