dynatree是一个jQuery的插件,用来在网页上显示树形控件的脚本。
示例代码:
<html><head> <!--1.IncludejQueryanddynatreelibraries:--> <scriptsrc='../jquery/jquery.js'type='text/javascript'></script> <scriptsrc='../jquery/ui.core.js'type='text/javascript'></script> <scriptsrc='../jquery/jquery.cookie.js'type='text/javascript'></script> <linkhref='../src/skin/ui.dynatree.css'rel='stylesheet'type='text/css'> <scriptsrc='../src/jquery.dynatree.js'type='text/javascript'></script> <scripttype='text/javascript'> //Addcodetoinitializethetreewhenthedocumentisloaded: $(function(){ //2.Attachthedynatreewidgettoanexisting<divid="tree">element // andpassthetreeoptionsasanargumenttothedynatree()function: $("#tree").dynatree({ //Passanarrayofnodes(andchildnodes) children:[ {title:"Item1"}, {title:"Folder2",isFolder:true,key:"folder2", children:[ {title:"Sub-item2.1"}, {title:"Sub-item2.2"} ] }, {title:"Item3"} ], onActivate:function(dtnode){ //Thisfunctioniscalled,whenanodeisclicked //ADynaTreeNodeobjectispassedasargument. alert("Youactivated"+dtnode.data.title); } }); }); </script></head><body> <!--3.Adda<div>elementwherethetreeshouldappear:--> <divid="tree"></div> [...]</body></html>
评论