[jQuery] How to bind to dynamic elements

[jQuery] How to bind to dynamic elements


I've a dynamically created array
var folders = new Array();
folders = <?PHP echo $json->encode ($folders) ?>;
and html created with
foreach ($folders as $key => $d) {
echo "<p id=\"f$key\" class=\"folder\">$d";
}
and would like to bind a click handler to each element like
for (var i in folders) {
$('#f'+i).bind('click', function() {
...
});
}
yet the "$('#f'+i)" seems to be wrong. Any idea how to do that?
O. Wyss