2

I've a little question, why this simple code does not work?

html:

<input type="text" name="a" id="a">
<input type="text" name="ab" id="ab">
<input type="text" name="b" id="b">
<input type="text" name="c" id="c">
<input type="text" name="d" id="d">

js:

$("[name^='a'][name='c']").css("background-color", "red");

Thanks in advance, ciao h.

1
  • what do you mean with does not work ? Commented Jun 24, 2011 at 10:24

3 Answers 3

9

You need to add comma to your selector:

$("[name^='a'],[name='c']").css("background-color", "red");
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks everybody for answering, I followed jquery documentation an there example not use comma :-(
3

You need to put a comma between expressions

$("[name^='a'],[name='c']").css("background-color", "red");

Comments

2

use comma to seperate your selectors

$("input[name^='a'],[name='c']").css("background-color", "red"); 

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.