I'm using jQuery Treeview. Is there's a way to populate a children开发者_C百科 node in a specific parent on onclick event? Please give me some advise or simple sample code to do this.
You can access the node with Javascript by using
document.getElementById('theParent')
.getElementsByTagName('firstHierarchyTag')[n]
.getElementsByTagName('secondHierarchyTag')[n]
...
Yes, it is possible, give us the HTML code then we will be able to give a very specific example.
// attach the treeview to the main ul
$("#mytree").treeview();
// listen for an event on a specific node
$("#mytreebranch").click(function() {
var children = "<li><span class='folder'>New Children</span>"+
"<ul><li><span class='file'>Sub-child 1</span></li>" +
"<li><span class='file'>Sub-child 2</span></li>" +
"</ul></li>";
children = $(children).appendTo("#mytree");
// add the new elements to the treeview
$("#mytree").treeview({
add: children
});
});
精彩评论