Reputation: 68680
<select name="search[quick_dates]" id="search_quick_dates">
...
</select>
and jQuery:
f.find('select[name=search[quick_dates]]').bind('change', { form: f }, function(e){
...
}
throws an error:
Uncaught Error: Syntax error, unrecognized expression: select[name=search[quick_dates]]
Can I update my jQuery instead of changing the attribute name?
Upvotes: 1
Views: 205
Reputation: 1299
You will need to escape brackets. But using single backslashes will not escape brackets because single backslash will escape the character in the string inside the function but you need backslash to be part of the expression or selector and hence you will also have to escape backslash by another backslash.
Try this:
f.find('select[name=search\\[quick_dates\\]]')
Upvotes: 1
Reputation: 85545
To use any of the meta-characters such as !"#$%&'()*+,./:;<=>?@[]^`{|}~ as a literal part of a name, it must be escaped with with backslashes:
Change it:
f.find('select[name=search[quick_dates]]')
To this:
f.find('select[name="search\\[quick_dates\\]"]')
Upvotes: 2