How to add javascript function to all div, which are generated dynamically. In _data_grid.html, div bucket is generated dynamically with id forloop.counter0. I want to add common javascript function. Like Show and hide the some portion of div.
All division are different and Want JavaScript function work separatel. How I will do that.
_data_grid.html
<section id="grid_content">
{% for row in rows%}
<div class="bucket" id="bucket{{forloop.counter0}}">
{{ row.render }}
</div>
{% empty %}
{{ table.get_empty_message }}
{% endfor %}
</section>
All division will work separately. Please see the following figure, If I click on hidecontent on 1st div then It will hide 1st div on other will hide, If I click on 2nd div then It will hide the 2nd div, no other div will hide.