Using each() for multiple selectors?
Hi,
The following code should check each input of type text and of type password and add a class to the input and it's label if the input has a value;
But it works only for inputs of type text, but not for inputs of type password!:
- function showAutoFillValue() {
- $('input[type=text], input[type=password]').each(function() {
- var input_value = $(this).val();
- if (input_value != '') {
- $(this).addClass('dirty').prev('label').addClass('dirty');
- }
- });
- }
- setTimeout(showAutoFillValue, 500);
Why is that?
Thanks