Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 72388

How can I use Django dynamic IDs in Javascript/Ajax?

$
0
0

I have a Django HTML file like this:

<button type="button" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}" class="btn btn-primary form-control">{{ choice.choice_text }}</button>

I have an Ajax .js file like this:

$(document).ready(function(){
$('#choice{{ forloop.counter }}').on('click', function(){
(...)

Where {{ forloop.counter }} obviously don't work.

What I could use to replace it in ajax?

Thank you


Viewing all articles
Browse latest Browse all 72388

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>