0

So I would like to know after form submitting if a checkbox is checked or not.

I used this lines:

var isChecked = $('#USR_RememberMe').attr('checked') ? true : false;
alert(isChecked);

But isChecked is equals to false each times.

Could you please help me ?

3
  • $('#USR_RememberMe').checked should also work. Commented Jul 14, 2015 at 23:54
  • possible duplicate of Testing if a checkbox is checked with jQuery Commented Jul 14, 2015 at 23:57
  • Try .prop() instead of .attr(). Also, note the "Attributes vs. Properties" section in the documentation for .prop(). Commented Jul 14, 2015 at 23:57

1 Answer 1

3

Do this:

$("#USR_RememberMe").is(":checked");

:checked is a pseudo class.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.