I've been working on a snippet of jQuery code that I'd like to tailor to be more specific for one of two different input elements on my HTML page.
<script>
// ensure only one box is checked at a time
$(document).ready(function() {
$('input:checkbox').click(function() {
$('input:checkbox').not(this).prop('checked', false);
});
});
</script>
These are the two inputs in question:
<div id="reponses-section" class="form-check">
<c:forEach items="${question.reponses}" var="reponse">
<input id="${reponse.id}" name="id-reponse" value="${reponse.id}"
type="checkbox" class="form-check-input">
<h5>${reponse.texte}</h5>
</c:forEach>
</div>
<div id="theme-btn" class="pull-right">
<label class="switch">
<input id="changeThemeBtn" type="checkbox" onclick="getTheme(this);" value="dark">
<span class="slider round"></span>
</label>
</div>
Would it be possible to assign an ID to the JavaScript code sample, and if so, what would be the correct syntax to do so?
Thank you for your help!