phillhw
06-07-2003, 11:36 AM
When using nest DIVs or SPANs to call a javascript function to display the node.firstChild.data, the function is called more than once and is called for every node right back to the start of the first DIV. If I replace the DIVs with nested P tags this does not occur. Anyone have any idea?
<html>
<head>
<title>Unexpected Result</title>
<style type="text/css">
<!--
.item {
border:1px solid #DDDDDD;
padding:5px;
margin:5px 5px 0px 15px;
display:block;
cursor:pointer;
}
//-->
</style>
<SCRIPT LANGUAGE="JavaScript">
<!--
function checkitem(node){
alert("firstChild.data : " + node.firstChild.data);
}
//-->
</script>
</head>
<body>
<div onclick="checkitem(this)" class="item">Document Root
<div onclick="checkitem(this)" class="item">Chapter 1
<div onclick="checkitem(this)" class="item">Section 1.1
</div>
<div onclick="checkitem(this)" class="item">Section 1.2
</div>
</div>
</div>
</body>
</html>
<html>
<head>
<title>Unexpected Result</title>
<style type="text/css">
<!--
.item {
border:1px solid #DDDDDD;
padding:5px;
margin:5px 5px 0px 15px;
display:block;
cursor:pointer;
}
//-->
</style>
<SCRIPT LANGUAGE="JavaScript">
<!--
function checkitem(node){
alert("firstChild.data : " + node.firstChild.data);
}
//-->
</script>
</head>
<body>
<div onclick="checkitem(this)" class="item">Document Root
<div onclick="checkitem(this)" class="item">Chapter 1
<div onclick="checkitem(this)" class="item">Section 1.1
</div>
<div onclick="checkitem(this)" class="item">Section 1.2
</div>
</div>
</div>
</body>
</html>