+1 vote
in Programming by (390 points)
I am trying to get click event in li using jstree please see the code

$('#uu').click(function () {
var ref = $('#tree').jstree(true),
    sel = ref.get_selected();

if (!sel.length) {
    sel = ref.create_node("#", {"id" : node_count+1, "text" : node_count+1});
} else
    sel = sel[0];
    sel = ref.create_node(sel, {"id" : node_count+1, "text" : node_count+1});
/*if (sel) {

Here in alert id of click event is not coming please help me out on this.

1 Answer

+2 votes
by (1.4k points)
selected by
Best answer
As here your li is coming dynamically, so you should get id like this , I hope this will help you.

$("#tree").on("click", "li > a", function() {
    var id = $(this).closest("li").attr("id");

Not a Member yet?

Ask to Folks Login

My Account

Your feedback is highly appreciated