1

I apologize for the simplicity of this question but for some reason I can't figure out for the life of me how to implement using $(this) in place of $("input:checked") when looping through inputs to validate a form. If $(this)is an input how do I concatenate :checked?

What I'm looking to do is start an if statement regarding the current iteration of input's checked value so rather than:

if ($("input:checked").val() === undefined) {
    //do something
}

something like this (but the below isn't working obviously, hence my question):

if ($(this) + (":checked").val() === undefined) {
    //do something
}

Any help would be greatly appreciated.

Christian Ternus
  • 8,406
  • 24
  • 39

1 Answers1

2

I think you'll want to use .is()

e.g.

if ($(this).is(":checked")) {
    //do something
}
Kyle Muir
  • 3,875
  • 2
  • 22
  • 27