I want to pass the dynamic id of the checkbox to jQuery in order to check whether the checkbox is checked or not. Consider the scenario:
<input type = 'checkbox' id ='myid<?= echo '1'; ?>' checked=''>checkbox1
<input type = 'checkbox' id='myid<?= echo '2'; ?>' checked=''>checkbox2
So the ids are: myid1
and myid2
. With the help of ids I need to get the current status of the checkbox. Suppose, if I check on checkbox1
it should give true
and if I uncheck it should give false
to me.
How do I get the id in JavaScript and retrieve the current status based on id?