Jean
Jean

Reputation: 5411

how get and element using jquery

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!

Upvotes: 0

Views: 67

Answers (4)

Jain
Jain

Reputation: 1249

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

Upvotes: 0

Milind Anantwar
Milind Anantwar

Reputation: 82231

You have error while selecting. You should use:

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

Link To Fiddle

Upvotes: 1

yent
yent

Reputation: 1343

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

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

Upvotes: 0

Dieterg
Dieterg

Reputation: 16368

use single quotes and it should work

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

fiddle

Upvotes: 2

Related Questions