I want to store the checked checkbox value and it's name in a two dimensional array, here is html code.
<h3>Select your favorite sports:</h3>
<label>
<input type="checkbox" value="football" name="football"> Football</label>
<label>
<input type="checkbox" value="baseball" name="baseball"> Baseball</label>
And I can only display the checked checbox values, here is jQuery code
$(document).ready(function () {
$("button").click(function () {
var favorite = [];
$.each($("input:checked"), function () {
favorite.push($(this).val());
});
alert("My favourite sports are: " + favorite);
});
});
My question is how to store both values and It's name in favorite array?