[Fixed]-Dynamic Javascript function in Django "for" loop

1πŸ‘

βœ…

In your Javascript, $('.description') returns a list of all the elements that have a class description, while the html() function

  • returns the content of the FIRST element when reading
  • modifies EACH element when updating

What you need is something like this (Not tested):

$('.description').each(function(index) {
  var str = $(this).html();
  var edt = ...;
  $(this).html(edt);
});
πŸ‘€Dric512

Leave a comment