JQUERY 實現無限極TREEVIEW

來源:互聯網
上載者:User

  第一步:下載JQUERY和TREEVIEW外掛程式。
         JQUERY:http://jquery.bassistance.de/dist/jquery.js
         TREEVIEW:http://jquery.bassistance.de/treeview/jquery.treeview.zip(注意:解壓后里面的DEMO是不能正常顯示的,因為缺少jquery.js。大家下載下來放到相應目錄即可)
        
         第二步:建立一個HTML檔案
         因為我們要利用一些圖片資源,所以就在jquery.treeview.zip解壓以後的目錄裡面建立。
         例如我們建立一個treeview.html檔案。用你喜歡的編輯器寫以下的代碼
        

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
        <title>TREEVIEW</title>
        這裡是引入jquery.js檔案,我上面已經提過原來的壓縮包是沒有的,下載以後複製進去即可。
        <script type="text/javascript" src="jquery.js"></script>
        這裡是引入treeview外掛程式
        <script type="text/javascript" src="jquery.treeview.js"></script>
        下面這個是jquery的文法格式,不懂的可以到上面看我給的那些入門資料。
        <script type="text/javascript">
        $(function(){
        $("ul").Treeview();
       
        });
        </script>
        以下是一些CSS樣式,這裡是必須的。大家可以根據自己的喜好來改它的外觀,這也是我特別欣賞       的地方
        <style type="text/css">
   
    .treeview, .treeview ul {
    padding: 0;
    margin: 0;
    list-style: none;
}   

.treeview li {
    margin: 0;
    padding: 4px 0 3px 20px;
}

.treeview li { background: url(images/tv-item.gif) 0 0 no-repeat; }
.treeview .collapsable { background-image: url(images/tv-collapsable.gif); }
.treeview .expandable { background-image: url(images/tv-expandable.gif); }
.treeview .last { background-image: url(images/tv-item-last.gif); }
.treeview .lastCollapsable { background-image: url(images/tv-collapsable-last.gif); }
.treeview .lastExpandable { background-image: url(images/tv-expandable-last.gif); }

    </style>
       
   
    </head>
    <body>
    
     大家可以根據自己的要求改下面的這些代碼,只要結構按照html語言裡的列表結構即可。

<ul>
<li>Item 1
<ul>
<li>Item 1.1</li>
</ul>
</li>
<li class="closed">Item 2 (如果CLASS指定了closed,那麼他預設是關閉的)
<ul>
<li>Item 2.1
<ul>
<li>Item 2.1.1</li>
<li>Item 2.1.2</li>
</ul>
</li>
<li>Item 2.2</li>
</ul>
</li>
<li>Item 3</li>
</ul>

    </body>
</html>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.