jQuery .on() click event catching dynamic 'data-' attribute in list of buttons to pass value to other function?

前端 未结 5 1187
误落风尘
误落风尘 2021-02-07 04:57

I have a dynamic table list of around 40 rows each with an edit button containing a date field. I also have the following click event script trying to attach to each button via

5条回答
  •  不思量自难忘°
    2021-02-07 05:14

    If your data attribute is known, you can do it directly with an attribute selector in jQuery, like this:

    $(document).on('click', "[data-attribute]", function() {
        // Do your tricks here...
    });
    

提交回复
热议问题