易截截图软件、单文件、免安装、纯绿色、仅160KB

javascript 遍历树节点

如题!
javascript 如何遍历树节点,可得到节点的 title 值
ding

引用
ding


谢谢

你可以通过id的规律遍历,为通用起见我写了个递归函数如下:
HTML code:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function Iterate()
{
var tv = document.getElementById("tv1");

Curve(tv);
}


function Curve(p)
{
for(var i=0;i<p.childNodes.length;i++)
{
var tc = p.childNodes[i];
if(tc.tagName=="TABLE")
{
var a = tc.rows[0].cells[tc.rows[0].cells.length-1].firstChild;
alert(a.getAttribute("title"));
}
else if(tc.tagName=="DIV")
{
Curve(tc);
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="button" value="Iterate" onclick="Iterate()" />


相关问答:

Javascript 树展开,折叠的问题!谢谢高手

树HTML
<div id="DataTreeView" class="dtree" onclick="treeview_click(this);">
  <Table> 展开 OR 折叠 </Table>
    <DIV> ......

新人来此跪求解答javascript 表单验证功能失效

function check(){
 
  if(document.form1.LXRMC.value=="" || document.form1.DZ.value=="" || document.form1.LXRMC.value==""
  || document.form1. ......

vc html javaScript脚本语言打不开应用程序

我模仿“实现网络蚂蚁、JETCAR等软件之IE右键菜单的“用xxxxxx下载”例子,”在ie右击菜单弹出一个应用程序,在我的机子上运行能实现效果,但是我把运行好的程序打包到另一机子上(“HKEY_CURRENT_USER\Software\Mic ......

在JavaScript里访问C#变量

.cs文件里代码:
string ss="12345";
protected void Page_Load(object sender, EventArgs e)
{
  ClientScript.RegisterStartupScript(this.GetType(), "", " <scrip ......

如何用javascript控制多重frame

如下的框架定义:
<frameset cols="100,*">
  <frame name="left" src="a.html">
  <frameset rows="80,*">
    ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号