In the following Javascript, I would like to replace all text beginning with "#" to become a link and change the color. The function works fine, but it changes all of the descriptions on the page instead of each photo individually. Is there a way to have it work for each photo in the for loop?
Javascript:
var str = $('.description').html();
var edt = str.replace(/(^|\s)(#[a-z\d-]+)/ig, "$1<a href='{% url "timeline" %}'><span style='color: blue;'>$2</span></a>");
$('.description').html(edt);
Django:
{% for photo in photos %}
<div class="photo-item">
<p class="description">{{ photo.description }}</p>
</div>
{% endfor %}
Thank you in advance!