jQuery .click() not working?

前端 未结 4 1118
挽巷
挽巷 2021-01-14 03:57

I generate the set of buttons within html table as follows and then I want to call to function when it click.

$.each(childData, function(key, item) {
    va         


        
4条回答
  •  盖世英雄少女心
    2021-01-14 04:46

    Delegate the event to static parent:

    $(div).on("click", ".download", function(){  
    

    Here div can be the static parent which was available when page was loaded at first load. Although document or body can also be used in place of div.


    As you have not presented how you create div element but one thing has to be noticed that you are generating an invalid markup. As a td element can't be a child of div but table's tr.

提交回复
热议问题