I have on my web-page 5000 cards. Each card contains a checkbox. All of the cards and the checkbox were created with jQuery when the webpage was loaded.
'''
function createTitleAndToggleButtonInContainer(titleAndToggleContainer, coinData) {
$("<h5></h5>", {
"class": "card-title",
text: coinData.id
}).appendTo(titleAndToggleContainer);
let toggleContainer = $("<div></div>", {
"class": "switch"
});
let input = $("<input>", {
"type": "checkbox",
"name": "toggle",
}).appendTo(toggleContainer);
'''
This piece of code is called 5000 times. I want to add an event handler for the checkbox. If the user checks more than 5 checkboxes - a modal window will display with the IDs of the cards. I will have a global counter and each time a checkbox will be checked the counter ++.
I need a way to know which checkbox was checked because I need to know the ID of the cards it came from. What is the best way to set an event handling with jQuery to the checkbox and the most important is how to have the ability to know which checkbox was clicked
Thanks for the helpers
Aucun commentaire:
Enregistrer un commentaire