I have a Django template with the following code which creates multiple buttons and tries to delete/hide one of them on a click (on the same button):
{% for h in helicopters %} <div class="btn-group" id="remove-heli"> <button type="button" class="btn btn-default" onclick='my_func("{{ h }}")'> {{ h }} </button> </div> {% endfor %} where helicopters is a list of strings, and later in the script block I have
function my_func(h) { document.getElementById('remove-heli').style.visibility = 'hidden'; } The function runs, but as you may expect, it runs only on the first element of my for loop, because all the <\div> elements in the for loop have the same id.
My question is: is there a way to point to the particular element? or alternatively, is there a better way to print buttons next to each other?