15

I have a Javascript that I am working on and I would like to combine two selectors so that they refer to this tag only:

<input name="checkable" type="checkbox">

So that only checkable with type checkbox will react to it while a text-field with a name of checkable will not. I have tried:

$("input[name='checkable' type='checkbox']")

with no success. Any ideas on how I can do this?

3
  • BTW: Do you have multiple input elements with the same control name but of different type? Commented Aug 24, 2011 at 15:42
  • Yes they have the same name one is a checkbox one is a text field Commented Aug 24, 2011 at 15:43
  • Roger that :) Just making sure that this was actually the right approach. Commented Aug 25, 2011 at 8:42

1 Answer 1

37
$("input[name='checkable'][type='checkbox']")

Cf. Multiple Attribute Selector [name="value"][name2="value2"].

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

1 Comment

Thx! this helped me to avoid do innecesary loops.

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.