Get an element's ancestor node based on it's id?



Is it possible in JavaScript to to get the ancestor element of the <a>
element below that has an id beginning with 'panel'

<div id='panel1'>
<div>
<a href="#" onclick="closeDiv(getPanel());">Close</a>
</div>
</div>

The idea being is that the getPanel() returns the 'panel' element &
passes it as a parameter to the closeDiv() function without having to
explicitly specify 'panel1', 'panel2' etc...

I am trying to learn how to navigate the DOM but this has me stumped!

thanks in advance

harry

.



Relevant Pages