Answer the question
In order to leave comments, you need to log in
How to select the correct comment on a page using jquery?
Hello.
I do ajax to the likes button on the comments. Can't figure out how to select the right element to interact with.
There is a For loop that displays comments on the page:
{% for com in com_view %}
<div class="comment">
<p class="comments_nickname">
<a href="{% url 'profile' com.user_link.id %}"><span class="profile_link_comment">{{ com.user_link }}</span></a> | {{ com.comdata }}
</p>
<p class="comments_social_counter"><a id="up_com_video_like" class="comments_social_thumb" href="{% url "upvideocomlike" com.id %}"></a><span id="com_like_number">{{ com.get_plus }}</span></p>
<p class="comments_main_text">{{ com.comtext }}</p>
<hr>
</div>
{% endfor %}
<script type="text/javascript">
$('#up_com_video_like').click(function(e){
e.preventDefault();
$.ajax({
url: '{% url "upvideocomlike" com.id %}',
success: function(data){
$('#com_like_number').html(data.count_like)
}
});
});
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question