原文:
<
script
src
=
"http://libs.baidu.com/jquery/1.9.0/jquery.js"
></
script
>
<
script
src
=
"http://libs.baidu.com/jqueryui/1.8.22/jquery-ui.min.js "
></
script
>
<
script
src
=
"jquery.jOrgChart.js"
></
script
>
<
script
>
jQuery(document).ready(function() {
$("#org").jOrgChart({
chartElement : '#chart',
dragAndDrop : true
});
});
</
script
>
</
head
>
<
body
onload
=
"prettyPrint();"
>
<
div
class
=
"topbar"
>
<
div
class
=
"topbar-inner"
>
<
div
class
=
"container"
>
<
a
class
=
"brand"
href
=
"#"
>jQuery Organisation Chart</
a
>
<
ul
class
=
"nav"
>
<
li
><
a
href
=
"http://github.com/wesnolte"
>Github</
a
></
li
>
<
li
><
a
href
=
"http://twitter.com/wesnolte"
>Twitter</
a
></
li
>
<
li
><
a
href
=
"http://th3silverlining.com"
>Blog</
a
></
li
>
</
ul
>
<
div
class
=
"pull-right"
>
<
div
class
=
"alert-message info"
id
=
"show-list"
>Show underlying list.</
div
>
<
pre
class
=
"prettyprint lang-html"
id
=
"list-html"
style
=
"display:none"
></
pre
>
</
div
>
</
div
>
</
div
>
</
div
>
<
ul
id
=
"org"
style
=
"display:none"
>
<
li
><
br
><
font
size
=
"4"
>Balance</
font
>
<
ul
>
<
li
id
=
"beer"
><
br
>redis 192.168.1.10</
li
>
<
li
><
br
>nginx2 192.168.1.13
<
ul
>
<
li
>mongodb 192.168.1.16</
li
>
<
li
>mongodb 192.168.1.19</
li
>
</
ul
>
</
li
>
<
li
class
=
"fruit"
>nginx3 192.168.1.24
<
ul
>
<
li
>php 192.168.1.28
<
ul
>
<
li
>mysql 192.168.1.33</
li
>
<
li
>mysql 192.168.1.37</
li
>
</
ul
>
</
li
>
</
ul
>
</
li
>
<
li
>spider 192.168.1.41</
li
>
<
li
class
=
"collapsed"
>nginx5 192.168.1.44
<
ul
>
<
li
>Topdeck</
li
>
<
li
>Reese's Cups</
li
>
</
ul
>
</
li
>
</
ul
>
</
li
>
</
ul
>
<
div
id
=
"chart"
class
=
"orgChart"
></
div
>
<
script
>
jQuery(document).ready(function() {
/* Custom jQuery for the example */
$("#show-list").click(function(e){
e.preventDefault();
$('#list-html').toggle('fast', function(){
if($(this).is(':visible')){
$('#show-list').text('Hide underlying list.');
$(".topbar").fadeTo('fast',0.9);
}else{
$('#show-list').text('Show underlying list.');
$(".topbar").fadeTo('fast',1);
}
});
});
$('#list-html').text($('#org').html());
$("#org").bind("DOMSubtreeModified", function() {
$('#list-html').text('');
$('#list-html').text($('#org').html());
prettyPrint();
});
});
</
script
>