js基础:网页特效之HTML中树的实现方法


利用javascirpt我们可以很容易的在HTML中实现树,而不需要使用ASP,JSP,PHP等等编写动态程序,当然如果要和数据库结合,下面的代码也很容易移植。

  首先,我们看一下实现这个树形结构的javascript代码。

  common.js
<!--
functionshowCurrentSection()
{ 
varobjCurrentSection=document.getElementById("navcurrentsection"); 
if(objCurrentSection!=null)
{
 objCurrentSection.style.display="block";  
 objCurrentSection.parentElement.childNodes[0].className="open";
 if(objCurrentSection.parentElement.parentElement.nodeName=="UL")
 showSection(objCurrentSection.parentElement.parentElement); 
}
}
functionshowSection(objSection)
{ 
objSection.style.display="block";
objSection.parentElement.childNodes[0].className="open"; 
if(objSection.parentElement.parentElement!=null&&objSection.parentElement.parentElement.nodeName=="UL")
 showSection(objSection.parentElement.parentElement);
}
-->


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3