jQuery click event not working after adding class

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

In my JSP page I added some links:

Organization Data


        
相关标签:
7条回答
  • 2020-11-22 02:48

    You should use the following:

    $('#gentab').on('click', 'a.tabclick', function(event) {
        event.preventDefault();
        var liId = $(this).closest("li").attr("id");
        alert(liId);  
    });
    

    This will attach your event to any anchors within the #gentab element, reducing the scope of having to check the whole document element tree and increasing efficiency.

    0 讨论(0)
提交回复
热议问题