0

I've tried to find some way to select all form inputs by class.

<form action="" class="registerForm">
   <input type="text" name="loginInput" class="registerInputField">
   <input type="email" name="emailInput" class="registerInputField">
   <input type="password" name="passwordInput" class="registerInputField">
   <input type="password" name="confirmPasswordInput" class="registerInputField">
   <input type="submit" value="Register">
   <input type="submit" value="Cancel">
</form>

I've tried: `

input.registerInputField{}
.registerForm > input[type=text]{}
input[type=text].registerInputField{}

I read a few topics related to this, but it didn't work. I'll be glad for showing me some source or a book where I can find the answer.

2
  • HTMLElement.getElementsByTagName('input') Commented Apr 1, 2020 at 18:28
  • 1
    @AdrianSolarczyk: You're not wrong, but that's JavaScript. Commented Apr 1, 2020 at 18:30

1 Answer 1

2

Every one of the examples you gave work. Without more context, such as whether you're using Angular which adds in scoping that might be relevant, it's impossible to say why you might experience it not working. But this clearly works:

input.registerInputField {
   background-color: purple;
}
<form action="" class="registerForm">
   <input type="text" name="loginInput" class="registerInputField">
   <input type="email" name="emailInput" class="registerInputField">
   <input type="password" name="passwordInput" class="registerInputField">
   <input type="password" name="confirmPasswordInput" class="registerInputField">
   <input type="submit" value="Register">
   <input type="submit" value="Cancel">
</form>

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

2 Comments

Thank you for help!
@Devin Burke Great

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.