jQuery
New Wave Javascript
discuss » Ancestors of a node
Posted: Mon Feb 20 06:53:52 EST 2006
From: Chris Double <
chris.double at double.co.nz
>
Is it possible, using jquery, to do something like find the nearest
enclosing div of a given node? For example:
<script>
function test(self) {
// somehow find the nearest enclosing 'div' around the 'a'.
}
</script>
<div>
...
<div> <!-- Find this one -->
<p>
...
<a href="#" onclick="test(this)">Press me</a>
</p>
</div>
</div>
I tried the ancestor xpath axes but I don't think it's implemented? Any ideas?
Chris.