Im creating a project of crypto using jQuery. I created a bunch of cards using $("#div'sId").append
inside for
loop. each toggle button (input type=checkbox
) have the same id name + a specific index
number he got from the for
loop.
Im trying to do 2 things:
- limit the selected checkboxes to 5
- send the specific
index
number of each selected checkbox to send data to another function
I tried to select the checkboxes id, class, and even [input type=checkbox] without any success.
Html (inside the JavaScript)-
for (let index = 0; index < coins.length; index++) {
$("#mainDiv").append(
<div class="form-check form-switch position-absolute end-0" style="transform: translateY(-35px);">
<input
class="form-check-input"
type="checkbox"
role="switch"
id="flexSwitchCheckChecked${index}"
style="background-color: rgb(62,138,152); border:rgb(5,19,20);"
/>
<label
class="form-check-label"
for="flexSwitchCheckChecked"
></label>
</div>
})
how can I do it?
**There are other elements inside the .append
function but they are not relevant