41

I have a text and a password input field that I'm trying to select in this fashion:

input[type=text][type=password]

however this does not work. I would refrain from using jQuery, so any help would be appreciated (without using custom classes).

0

1 Answer 1

80

You need to specify the attributes separately, repeating the types if necessary and using comma(s):

input[type=text], input[type=password]

Your given selector is trying to match an input with a type that is both text and password, but a single element can't have different values for the same attribute so it fails.

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

3 Comments

@AnthonyAlmighty: Possibly because this was a drive-by question, and most users who post once and never come back don't realize that answers can be accepted - they post a question, get an answer, and that's it. Plus, this feature is unnecessarily hard to discover.
What if I wanted these to have a certain class?
Because he ONLY wants input password AND input text to match

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.