One idea that comes to mind is creating a design with three lines - horizontal (starting from one element), vertical (going up or down), and then horizontal again (connecting to another element). To achieve this, you can set up two small columns without borders and dynamically add corresponding borders using jQuery's .css method.
If you want to animate these lines, consider starting with divs of size 0 and gradually increasing the size to reveal the borders.
Check out this basic example on jsFiddle: http://jsfiddle.net/3xPpc/
HTML:
<div class="big-col">
<div class="big-row blue"></div>
<div class="big-row green"></div>
<div class="big-row blue"></div>
<div class="big-row green"></div>
</div>
...
CSS:
.big-col {
float: left;
}
.small-col {
float: left;
}
.big-row {
width: 200px;
height: 100px;
}
.blue {
background-color: blue;
}
.green {
background-color: green;
}
...
To implement the borders on click event using jQuery, simply add the necessary code for border styles.