I am adding objects dynamically, and I find that $(document).on('click', function(){//código});
does not work for me: /
I also tried with:
$(".tr").off('click').on('click', function(){//código});
I am adding objects dynamically, and I find that $(document).on('click', function(){//código});
does not work for me: /
I also tried with:
$(".tr").off('click').on('click', function(){//código});
I had the same problem, a long time ago solve it with: (note 1: I select table as an example, but you can change a parent of your class. tr)
$("table").on('click','.tr', function(){alert();});
(note 2: I do not recommend you use $ (document), since I also had the same problem) if you have doubts check this link: Events created dynamically
You should check your version of jquery, if it is 3+ it is probably that, or you could also make it at the moment of generating the elements, the first time import the script with this you will have the file loaded at the same time your elements