I am here today with a question to do with key value pair arrays.
my html is as follows
<input type="checkbox" class="data" id="task_checked" value="1" email="[email protected]">
<input type="checkbox" class="data" id="task_checked" value="2" email="[email protected]">
I would like to store the following data as an array like below:
"1" => "[email protected]"
"2" => "[email protected]"
My Javascript currently is as follows:
var newTasksArr = new Array();
$("#task_checked:checked").each(function() {
var email = $(this).attr("email");
var id = $(this).val();
newTasksArr['id'] = email;
});
Perhaps I am using the Jquery .each() wrong, could someone shed some light in to my question please?
Thank you for you reading. Regards.