Inside my razor view, there is some text with corresponding CheckBox. That CheckBox has an id value. I want to send this id value to the MVC controller.
My simplified view has generated content like this:
<input id="14" class="imgCheckbox" type="checkbox">
<input id="deleteImgBtn" class="deleteImagesBtn"
type="button" value="Delete" name="deleteImgBtn">
Inside my javascript, I'm trying to gather all checked items and store them inside array which will be sent to the controller, again simplified:
var imgList = [];
$(document).on("click", "#deleteImgBtn", function (e) {
e.preventDefault();
$('.imgCheckbox:checked').each(function () {
var id = $(this).attr('id');
alert(id);
imgList.push(id);
});
...
On alerting id variable, I'm getting object Object.
I don't see what I'm doing wrong and how to see if checked id value is stored inside the imgList array.