簡體   English   中英

在php頁面上以樹狀視圖顯示數據

[英]Displaying Data in tree View on a php page

我有一個網站(Php和Javascript),在左側我想顯示類別和相應的SubCategories。

該樹應該是可移動的,例如此鏈接http://www.xtlinks.com/articles/

請建議我該怎么辦。

查看A List Apart-那里有很多很好的例子。

對於崩潰影響,請查看jQuery的.slide()方法。

這兩個鏈接可以很好地說明問題。

http://www.howtocreate.co.uk/tutorials/jsexamples/listCollapseExample.html

http://code.stephenmorley.org/javascript/collapsible-lists/

或只需嘗試一下。

<html>
<head>
    <script type="text/javascript">
    function changeDisplayState(sBoxId)
    {
    if (document.getElementById) {
    oBox = document.getElementById(sBoxId).style;
    if (oBox.display == "none" || oBox.display == "NULL") {
    oBox.display = "block";
    } else {
    oBox.display = "none";
    }
    }
    }
</script>
</head>


<body>
        <ul>
<li>parent 1</li>
<li><a href="javascript:changeDisplayState('childset_1')">parent 2</a>
<ul id="childset_1">
<li><a href="javascript:changeDisplayState('grandchildset_1')">child 1</a>
<ul id="grandchildset_1">
<li>grandchild 1</li>
</ul>
</li>
</ul>
</li>
</ul>
</body>
</html>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM