Re: Get an element's ancestor node based on it's id?
- From: "liamgegan@xxxxxxxxx" <liamgegan@xxxxxxxxx>
- Date: Thu, 31 Jan 2008 11:57:39 -0800 (PST)
getPanel=function()
{
var t=document.getElementById('li_id').parentNode;
while (!t.id && t!=document.body)
t=t.parentNode;
return t;
}
Sorry, allow me to clarify this code, I just re-read it and it's a
little ambiguous.
function closeDiv(div)
{
div.style.display='none';
}
getPanel=function(element)
{
var t=element.parentNode;
while (!t.id && t!=document.body)
t=t.parentNode;
return t;
}
and update your HTML to look like:
<div style="display: none;" id="panel1">
<div>
<a href="#" onclick="closeDiv(getPanel(this));return
false">Close</a>
</div>
</div>
.
- References:
- Get an element's ancestor node based on it's id?
- From: harryajh
- Re: Get an element's ancestor node based on it's id?
- From: liamgegan@xxxxxxxxx
- Get an element's ancestor node based on it's id?
- Prev by Date: Re: Get an element's ancestor node based on it's id?
- Next by Date: Re: CPU Creating Objects vs Modifying Object Properties
- Previous by thread: Re: Get an element's ancestor node based on it's id?
- Next by thread: Multiple form weirdness in IE6
- Index(es):
Relevant Pages
|