0

I am trying to get the value of a checkbox and I tried the following:

var closedIssue = $('#closed-' + rowCounter).val();

but it always return 'on'

Here is the checkbox

<input type="checkbox" name="closed-' + rowCounter + '" id="closed-' + rowCounter + '" />

What am I doing wrong?

0

2 Answers 2

2
var returnCheck = $('#closed-' + rowCounter).is(':checked');

will return you current status of checkbox.

Sign up to request clarification or add additional context in comments.

Comments

0

Get the checked property using the .prop() method instead. It will return a boolean.

var closedIssue = $('#closed-' + rowCounter).prop('checked');

Or plain JavaScript:

var closedIssue = document.getElementById('closed-' + rowCounter).checked;

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.