实现栏目页点击父栏目展开子栏目效果。

来源:互联网 发布:用友u8软件安装教程 编辑:程序博客网 时间:2024/04/29 05:41

解决方法:

示例模板下载地址:http://download.csdn.net/detail/u010205757/5295455

示例模板中js代码如下

<script type="text/javascript">

function selectLayer1(obj)

{

       var tabs = document.getElementById("tagtab");

       for(var i=0;i<tabs.children.length;i++){

              if(obj.abbr==tabs.children[i].id){

                     tabs.children[i].className="new_mulu";

              }else{

                     tabs.children[i].className="new_mulu1";

              }

       }

 

       document.getElementById("tagtitle").innerText = obj.innerText;

}

 

function showztxxsubs(){

       var obj = document.getElementById("ztxxsubs");

       if(obj.style.display=="none"){

              event.srcElement.parentElement.children[0].children[0].width="7";

              event.srcElement.parentElement.children[0].children[0].height="7";

            event.srcElement.parentElement.children[0].children[0].src="/jcms/jcms_files/jcms1/web1/site/picture/1/110411105951811.jpg";

              obj.style.display="";

       }else{

              event.srcElement.parentElement.children[0].children[0].width="7";

              event.srcElement.parentElement.children[0].children[0].height="7";

            event.srcElement.parentElement.children[0].children[0].src="/jcms/jcms_files/jcms1/web1/site/picture/1/110411105951811.jpg";

              obj.style.display="none";

       }

 

}

 

设参代码如下:

父栏目:

<!--for-->

<table onclick="showjgszsubs()"  width="95%" height="31" border="0" align="center" cellpadding="0" cellspacing="0" style=" cursor:pointer" >

 <tr> 

  <td width="40" align="center"><!--colunmheader--></td>

  <td align="left"   style="color:#5b5b5b; font-size:14px" ><a style="font-size:14px; color:#5b5b5b; TEXT-DECORATION: none" href='<!--columnurl-->'  ><!--columnname--></a></td>

  </tr>

  </table>

 <!--/for-->

子栏目:

<table width="95%" height="31" border="0" align="center" cellpadding="0" cellspacing="0" style="display:none;"id="jgszsubs" >

<!--for-->

 <tr >

  <td width="20" ></td>

  <td width="20" align="right">

    </td>

  <td align="left" id="jsbj" abbr="lb_mjwx" onclick="selectLayer1(this)"  height="24" nowrap="nowrap" style=" color:#5b5b5b" >&nbsp;&nbsp;<a href='<!--columnurl-->'  style="color:#5b5b5b; font-size:12px; text-decoration:none;" ><!--columnname--></a></td>

  </tr>

   <!--/for-->

  </table>

 

原创粉丝点击