Click here to Skip to main content
15,888,014 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
the actual tree generally we that in our data structure book....
share css link with me
Posted

You can create a treeview using li and ul tags.
And for the click function a tag inside the li if needed
 
Share this answer
 
v2
CSS alone cannot do that, there may be a lot of childs, who are not going to write a CSS child selector for N elements, are you? For this reason JavaScript is used to create a loop for those N elements, and to attach a visual representation (or a class to each of those elements). This way, the first element is parent then later ones are simply files or child folders and so on.

There are many libraries already provided online, Google for treeview jquery[^]. You will get more than 20 plugins to chose from. jsTree[^] is one of them.
 
Share this answer
 
For N elements a loop has to made with ul and li
$("#dataTree").append($(""))

Code For the above tree view

$("#dataTree").append($("<ul><li><a>Tree View</a><ul><li><a href="#">Tree</a></li></ul></li></ul>")


where

Datatree is a div. In this way n elements can be added to it. This is without any plugin
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900