Jaws - coming soon - testers and advice wanted
Chris Double
chris.double@REDACTED
Mon Feb 20 13:29:11 CET 2006
On 2/20/06, Joe Armstrong (AL/EAB) <joe.armstrong@REDACTED> wrote:
> I want bar() to compute the id if the nearest containing div - in this
> case "foo" any ideas how to do this? - do I really have to "walk the
> tree" from the root of the DOM tree?
Some javascript code to do this:
---------------8<-------------------
<script>
function enclosingDiv(node) {
while(node && node.nodeName != "DIV") {
node = node.parentNode;
}
return node;
}
function bar(self) {
var node = enclosingDiv(self);
if(node)
alert(node.id);
else
alert("No Div node");
return false;
}
</script>
<div id="foo">
<div id="baz">
<a onclick="bar(this);" href="#"><div>click</div></a>
</div>
</div>
---------------8<-------------------
This should alert with 'baz', the nearest enclosing div.
Chris.
--
http://www.bluishcoder.co.nz
More information about the erlang-questions
mailing list