JQuery. Check value of select box and textbox with same class, Is it possible?

Posted by Cesar Lopez on Stack Overflow See other posts from Stack Overflow or by Cesar Lopez
Published on 2010-05-07T11:38:29Z Indexed on 2010/05/07 11:48 UTC
Read the original article Hit count: 221

Filed under:
|

I have several select boxes and textboxes with the same class and I have the following statement.

if ($('.selTxtClass:visible').val() == "") {
         $('.selTxtClass:visible').focus();
      }
}

If I do an alert with ($('.selTxtClass:visible').val()) it comes as undefined.

I want to check that the value of these elements are empty, but I cant see what is wrong with this if statement, could you give me a hand, please?

Thanks a lot.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-selectors