Good, I have this in my Jquery code:
$("#borrarImagen0").click(function() {
editarImagen(0);
});
$("#borrarImagen1").click(function() {
editarImagen(1);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
I want to do something like:
for(i = 0; i < 2; i++) {
$("#borrarImagen"+i).click(function() {
editarImagen(i);
});
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
But it's not working, I really do not understand why, because it's a simple loop, but it still does not work.
The problem is that I have another loop of these, but where there are 15 elements and if I have to make any changes it is very cumbersome to change it everywhere.
Look everywhere, but I did not find a way to solve it.