StackTrace
StackTrace

Reputation: 9416

unrecognized expression: jQuery syntax issue

 $("#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?

Upvotes: 0

Views: 1367

Answers (1)

dfsq
dfsq

Reputation: 193251

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.

Upvotes: 3

Related Questions