This would do the job. Since the li
is created dynamically, you need to delegate, which has been superseded by on.
$("#tree").on("click", "li > a", function() {
var id = $(this).closest("li").attr("id");
$(this).siblings(".jstree-icon").click();
alert(id);
});
EDIT: Making only the text clickable and not the arrow.
EDIT2: http://jsfiddle.net/GS4u3/8/ (edit 4, new jsfiddle with your change updated)
EDIT3: Edited code, to expand the tree upon clicking the text.