jQuery click event not working after adding class

前端 未结 7 1601
臣服心动
臣服心动 2020-11-22 01:47

In my JSP page I added some links:

Organization Data


        
7条回答
  •  盖世英雄少女心
    2020-11-22 02:29

    Since the class is added dynamically, you need to use event delegation to register the event handler

    $(document).on('click', "a.tabclick", function() {
        var liId = $(this).parent("li").attr("id");
        alert(liId);        
    });
    

提交回复
热议问题