0
 $("#divItemName input:[type='text']").val(itemName);

i have the above jQuery line of code. It works properly in jQuery 1.7.2 but in jquery-2.1.3, it throws the error below.

Error: Syntax error, unrecognized expression: #divItemName input:[type='text']

What is the correct syntax for this in jquery-2.1.3?

1
  • 1
    I've always used input[type='text'] Commented Feb 26, 2015 at 8:01

1 Answer 1

3

Valid CSS selector will be

$("#divItemName input[type='text']").val(itemName);

Colon : in front of attribute selector [type='text'] looks weird even for older jQuery version. While #divItemName input[type='text'] is perfectly valid CSS syntax, it's not jQuery specific thing.

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

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.