0

I'm trying to use a radio button as a click function:

$("input[type=radio]").click(function(){

and I don't just want radio buttons, I want radio buttons with the class 'baby', or I could even do it by name if that's easier, searched google and I can't find anything :(

3 Answers 3

4

How about this :

$("input[type=radio][class=baby]").click(function(){
Sign up to request clarification or add additional context in comments.

2 Comments

Or perhaps even simpler: input[type=radio].baby
.baby is preferable. [class=baby] won't match class="baby somethingElse"
1

You can have multplie selectors

$("input[type=radio]", ".baby").click(function(){}

Here you have nice examples

Comments

1

Use the first selector to globally pick up your inputs and then filter using a second selector.

$("input[type=radio]").filter(".baby")

Comments

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.