logRootInfo(); } function logRootInfo(){ console.log($("#root").mg_getInfos()); } function newWindow(){ var json=$("#tree0").mg_getJSONFromTree(); window.open("mgJQTreeExample2.php?tree="+json); } $(function(){ $(".tree").on("nodeDragged", function(event, draggedNode, newParent){ alert("Dragged: "+$(draggedNode).text()+". Its new parent is: "+$(newParent).text()); }); }); </script> </head> <body> <?php $tree->generateTree(); ?> <input type="button" value="Add new node" onclick="addNewNode()"> <input type="button" value="Display json object" onclick="toJSON()"> <input type="button" value="Open in new window" onclick="newWindow()"> <input type="button" value="Add some info to root" onclick="addInfo()"> </body> </html>