0

I know how to choose a element using the Attribute Equals Selector [name="value"] but I feeling a little lost when I try to find a check box by his name and value.

this is a example of the checkbox

<input id="check-box-nat-Español" name="kid[native_languages][]" type="checkbox" value="50f97f5304fec25b00000001">

I have a lot of checkbox with the same name, so I need to find the checkbox using the name and the value.

I'm trying this, but it did not work.

$("input[name="kid[native_languages][]"][value=50f97f5304fec25b00000001]").attr("checked",true);​

Any help please!

9
  • You have to use only one attribute at once thats it $("input[value=50f97f5304fec25b00000001]").prop("checked",true);​ Commented Feb 11, 2014 at 10:55
  • Did you mean that you have many checkboxes with same id? Commented Feb 11, 2014 at 10:56
  • 1
    @Jain You can use multiple attribute selectors... Commented Feb 11, 2014 at 10:57
  • Jain, I can't do that, beacuse I have two tipe of checkbox a group for native language and a group for practise language, so I have two checkbox whith the same value but whit different name Commented Feb 11, 2014 at 10:57
  • Sorry Garath, I wrote name Commented Feb 11, 2014 at 10:58

4 Answers 4

2

use single quotes and it should work

$("input[name='kid[native_languages][]'][value=50f97f5304fec25b00000001]").attr("checked",true);

fiddle

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

1 Comment

checked is not a attribute it is a property
1

You have error while selecting. You should use:

$("input[name='kid[native_languages][]'][value='50f97f5304fec25b00000001']").attr("checked",true)

Link To Fiddle

Comments

0

Use single quotes around your selector so that they wont interfere with the ones inside

$('input[name="kid[native_languages][]"][value=50f97f5304fec25b00000001]')

Comments

0
$("input[name='kid[native_languages][]'][value=50f97f5304fec25b00000001]").prop("checked",true);​

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.