Google ...">

Prototype hide div that has a specific link (<a href)

I have the following HTML:

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

      

I am using the prototype library. I need to hide a div that has a http://google.com link with it. Thanks.

+1


a source to share


3 answers


In the prototype:



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

      

+3


a source


You can use CSS for this.

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

      



and then in CSS:

#hideMe {
  display:none;
}

      

+1


a source


Is jQuery available ?

If so, use the following code:

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

      

If the parent is not necessarily the closest next level in the DOM, use .parents

instead:

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

      

However, this can affect at div

an even higher level in the tree.

0


a source







All Articles