0

What is the correct CSS selector for ASP.net checkboxes?

I tried input[type="checkbox"] + label , input[type="checkbox"] and input itself but none can select the checkbox.

2 Answers 2

1

ASP.NET CheckBox control produces HTML with input tag with type checkbox, so there should be no problem with standard CSS selectors.

I have copied a HTML produced by W3Schools example of using CheckBox control and tried input[type="checkbox"] + label selector and it worked - check this fiddle.

With this being said, I think your problem is somewhere else and you should carefully check yout code.

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

1 Comment

W3Schools is not W3C. Please don't get the two mixed up.
1

You don't need the quotes in the type argument.

To get the checkbox itself,

input[type=checkbox]

To get the label text,

input[type=checkbox] + label

1 Comment

You don't need them, but that doesn't mean you can't have them there.

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.