jQuery Syntax error, unrecognized expression: [name=Basics.Gender]

superlogical picture superlogical · Aug 7, 2012 · Viewed 31.9k times · Source

I am upgrading from jQuery 1.4.4 to jQuery 1.7.2 and I get a syntax error. I think its due to the '.' in the Basics.Gender part of the selector.

$('[name=Basics.Gender]')

Anyone have any suggestions on how to fix this?

http://jsfiddle.net/2nBc9/

EDIT

Anyone know why the '.' breaks the selector syntax now? Are they using regex's or something in Sizzle? Or has it always been best practice to put the attribute in quotes?

Answer

Esailija picture Esailija · Aug 7, 2012

Quote the value:

$('div[name="Basics.Gender"]')

http://jsfiddle.net/7Pqhc/