I'm displaying a list of checkboxes using this code :
{% for keyword in keywords %}
<div class="col m4 s12">
<p class="range-field">
<input type="checkbox" id="{{loop.index}}" name="{{keyword.title}}" class="filled-in"/>
<label for="{{loop.index}}">{{keyword.title}}</label>
<input type="range" min="0" max="100"/>
</p>
</div>
{% endfor %}
After sumbitting the form the server gets the list of selected checkboxes and sends them back so that I can check them back
{% for keyword in selected_keywords %}
<script>
$("label:contains('{{keyword.keyword}}')").prev().attr('checked',true);
</script
{% endfor %}
I'm using contains as selector but it doesn't work for innerHTML. For example if I have java and javascript and i only check java after submitting javascript is also checked. I searched for other related problems and most of them seem to use contains which does not work for specific innerHTML.