Я сделал небольшие изменения в html. Итак, согласно моему предположению, измененному, как показано ниже,
HTML:
$(document).ready(function() {
$('input[type=checkbox]').change(function() {
if (this.checked) {
$(this).next().addClass( "yourClass" ) // I assume you wanted to add class to text element
$(this).next().css("text-decoration-line", "line-through");// I assume you wanted to strike out the text on clicking checkboxes
} else {
$(this).next().removeClass( "yourClass" )
$(this).next().css("text-decoration-line", "none");
}
});
});
.yourclass{
color: red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="p-3 bg-white">
<div class="d-flex align-items-center">
<label>
<input type="checkbox" class="option-input radio">
<span class="label-text">Task list and assignments</span>
</label>
</div>
<div class="d-flex align-items-center">
<label>
<input type="checkbox" class="option-input radio">
<span> Set due date and assignments<span>
</label>
</div>
<div class="d-flex align-items-center">
<label>
<input type="checkbox" class="option-input radio">
<span> Remove duplicate tasks and stories<span>
</label>
</div>
<div class="d-flex align-items-center">
<label>
<input type="checkbox" class="option-input radio">
<span> Update the userflow and stories<span>
</label>
</div>
<div class="d-flex align-items-center">
<label>
<input type="checkbox" class="option-input radio">
<span> Adjust the components<span>
</label>
</div>
</div>
jquery:
$(document).ready(function() {
$('input[type=checkbox]').change(function() {
if (this.checked) {
$(this).next().addClass( "yourClass" ) // I assume you wanted to add class to text element
$(this).next().css("text-decoration-line", "line-through");// I assume you wanted to strike out the text on clicking checkboxes
} else {
$(this).next().removeClass( "yourClass" )
$(this).next().css("text-decoration-line", "none");
}
});
});