In my HTML structure, I have a parent node with one or more child nodes nested under it. The requirement is that if the parent node contains at least one child node, it should display "hellooo", and if there are no child nodes, it should show "hi".
However, the current implementation does not always work as expected. Sometimes it displays "hi" and other times it shows "helllooo".
Below is the code snippet:
function checkChildNodes() {
var treeViewData = window["<%=items.ClientID%>" + "_Data"];
//if (treeViewData.selectedNodeID.value != ""){
var selectedNode = document.getElementById(treeViewData.selectedNodeID.value);
if (selectedNode.childNodes.length >= 1) {
return confirm("heloo");
}
else {
return confirm("hi");
}
return false; // do not submit form
}