Reputation: 33372
I have recntly updated my jquery from 1.4 to 2.1 and an error started appeared.
In my code I have a part where I select the elements with by an id.
jQuery("*[id^=name:]")
That produces an error, however there were no errors before(1.4)
If I escape the colon than the error disappears. Have they added anything new in the latest version or is it just a bug in my code?
Upvotes: 0
Views: 364
Reputation: 388366
you can wrap the attribute value like a string literal
jQuery('*[id^="name:"]')
Demo: Fiddle
Upvotes: 4
Reputation: 38112
You can escape it by double backslashes. From the docs:
To use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[]^`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \\
jQuery("*[id^=name\\:]")
or wrap your value inside double quotes:
jQuery('*[id^="name:"]')
Upvotes: 2