I am trying to figure out how to check if all input elements in a particular form have a certain class, without checking each one individually if possible.
I know how to check if a single element has a class..
if( $('#element').hasClass('class') ){ Do This...}
I also know how to affect all inputs of a form with with a single line of JQuery.
$('#form > *').on('click', function(){ Do This...});
I just cant seem to blend the two…like…
if( $('#form > *').hasClass('class') ){ Do This...}
Just check if the count of inputs in form is equal to count of inputs in form with desired class:
Here, have a fiddle: http://jsfiddle.net/adrianonantua/2GnaW/
Update
An alternative approach: check if there’s any input in form that does not have yourclass.