CalebC
CalebC

Reputation: 952

Unrecognized expression when using special ID

I have the following code in my jQuery Mobile 1.2 project. It was working fine until I upgraded from jQuery 1.7.2 to jQuery 1.8.3.

<input type="text" id="a['val']" name="a['val']" />

When the page is loaded, it throws

Syntax error, unrecognized expression: label[for='a['val']']

and the page refuse to load. Although there's no label in my code, the error thrown is asking for a label. This problem only occurs specifically in jQuery 1.8 and it's working fine for 1.9 and versions prior to 1.8.

Here's the Fiddle with problem on 1.8.3 + JQM 1.2

Here's the Fiddle without problem on 1.9.1 + JQM 1.2

Upvotes: 0

Views: 328

Answers (1)

Bigxiang
Bigxiang

Reputation: 6692

I think it is a bug or feature in jQuery 1.8 + jqm 1.2, it occurs when you have an id containing '

JQuery can't transfer it to a selector of the label correctly and throw the error, you can modify the id to "a[val]" or 'a["val"]', then it's ok.

<input type="text" id='a["val"]' name="a['val']" />

see fiddle

Upvotes: 1

Related Questions