2

I thought that i could do this:

i[1] = 23; // this is built from a regex

$('select [name="sys_map\\['+i[1]+'\\]"]').css('border-color', '#FF5C5C');

or maybe

$('select [name=sys_map\\['+i[1]+'\\]]').css('border-color', '#FF5C5C');

to select

<select name="sys_map[23]">

quoting the name shows error:

[15:36:27.647] Error: Syntax error, unrecognized expression: select [name="sys_map[1]"

0

1 Answer 1

5

You have a space between 'select' and the name attribute selector, so you're looking for elements that match the attribute selector which are descendants of the select.

Change

$('select [name="sys_map\\['+i[1]+'\\]"]')

To

$('select[name="sys_map['+i[1]+']"]')

Here's a fiddle:

http://jsfiddle.net/NyAkm/

Note I had to change your array definition:

var i = [];
i[1] = 23;
Sign up to request clarification or add additional context in comments.

4 Comments

dang it.. now i feel stupid... I have looked at so many QA's and was focusing on the brackets, backslashes and quotes.. did not realize the space.... Thanks.
@SmithSmithy Happens to everyone. Also, looks like ᾠῗᵲᄐᶌ is correct, the slashes aren't needed. jsfiddle.net/NyAkm
hopefully someone else stumbles on this and it helps
If you don't have the quotes you need the to escape the [

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.