if($(\'#term\').children().length == 0){
$(\"#term\").append(\"
\");
var i;
for(i=1;
do something like:
$("#term").append("
");
var i;
for(i=1;i<=3;i++){
var liDynamic = "Term "+i;
var liId = "Term"+i;
var $li = $("", {
"id" : liId,
"class" : 'listDynamic'
}).html(liDynamic).click(function() {
alert("clicked:" + this.id);
});
$("#ulDynamic").append($li);
}
$("#ulDynamic").find("li:first").trigger("click");
Demo :: jsFiddle