Treeview

简单介绍一下JQUERY中的插件Treeview的用法,

    * animated :string/number树形动作的速度,主要参看animate()函数。
     eg:$("test").treeview({
        animated: "fast"
          })
  collapsed :Boolean
   设置为True:所有的文件枝是关闭状态
   设置为False(默认):所有文件枝是打开的状态
   eg:
   $("test").treeview({
   collapsed: true
    })
  unique :Boolean
   设置为True:一个层次上只允许一个分支是打开的
   设置为False(默认):一个层次上可以同时打开多个分支
   eg:
   $("test").treeview({
   unique : true
    })
  control :Selector
  放置treecontrol的容器的id,treecontrol就是通过一个点击按钮可以展开,合并以及切换分支。
  $("#test").treeview({
       animated: "fast",
       collapsed: true,
       control: "#sidetreecontrol",
   });
   ......
  <div id="sidetreecontrol"><a href="?#">Collapse All</a> | <a href="?#">Expand All</a></div>
   ......
   persist :string
    ```
*  在cookie中或是网页位置上保持树的状态,如果设置为“cookie”,保持树形的每一个click点击操作到cookie中,当重新加载树形结构的时候,就恢复这些树形的状态。If set to "location", looks for the anchor that matches location.href and activates that part of the treeview it. Great for href-based state-saving. 
  (如需要更加详细的了解这个插件,可到上面提供的官方网站上查看)

* 如何在你定义好的id为"test"的容器中安排好你的树形结构:
* 主要是通过ul和li这两个标签我做的:
   <ul>...</ul>: ul标签里面包含一些分支
   <li>...</li>: 分支的具体定义在li标签里面

* 简单事例说明:
 ```
[xhtml] view plain copy
     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  
                    "http://www.w3.org/TR/html4/loose.dtd">  
    <html>  
    <head>  
      <mce:script src="http://code.jquery.com/jquery-latest.js" mce_src="http://code.jquery.com/jquery-latest.js"></mce:script>  
      <link rel="stylesheet" href="http://dev.jquery.com/view/trunk/plugins/treeview/jquery.treeview.css" mce_href="http://dev.jquery.com/view/trunk/plugins/treeview/jquery.treeview.css" type="text/css" media="screen" />  
      <mce:script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/treeview/jquery.treeview.js" mce_src="http://dev.jquery.com/view/trunk/plugins/treeview/jquery.treeview.js"></mce:script>  
      <mce:style type="text/css"><!--  
      #browser {  
        font-family: Verdana, helvetica, arial, sans-serif;  
        font-size: 68.75%;  
      }  

--></mce:style><style type="text/css" mce_bogus="1">      #browser {  
        font-family: Verdana, helvetica, arial, sans-serif;  
        font-size: 68.75%;  
      }  
      </style>  
      <mce:script type="text/javascript"><!--  
      $(document).ready(function(){  
        $("#browser").treeview();  
     $("#add").click(function() {  
         var branches = $("<li><span class='folder'>New Sublist</span><ul>" +  
             "<li><span class='file'>Item1</span></li>" +  
             "<li><span class='file'>Item2</span></li>" +  
             "</ul></li>").appendTo("#browser");  
         $("#browser").treeview({  
             add: branches  
         });  
     });  
      });  

// --></mce:script>  

    </head>  
    <body>  

      <ul id="browser" class="filetree">  
         <li><span class="folder">Folder 1</span>  
             <ul>  
                 <li><span class="file">Item 1.1</span></li>  
             </ul>  
         </li>  
         <li><span class="folder">Folder 2</span>  
             <ul>  
                 <li><span class="folder">Subfolder 2.1</span>  
                     <ul id="folder21">  
                         <li><span class="file">File 2.1.1</span></li>  
                         <li><span class="file">File 2.1.2</span></li>  
                     </ul>  
                 </li>  
                 <li><span class="file">File 2.2</span></li>  
             </ul>  
         </li>  
         <li class="closed"><span class="folder">Folder 3 (closed at start)</span>  
             <ul>  
                 <li><span class="file">File 3.1</span></li>  
             </ul>  
         </li>  
         <li><span class="file">File 4</span></li>  
       </ul>  

       <button id="add">Add!</button>  
    </body>  
    </html>  
  • 本文章转载他人,记录自己的学习过程的参照物,方便以后使用查找
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值