I have a jQuery function to prettify radio buttons that works great except under one circumstance, when the name attribute of the button contains a bracketed array value.
This is for a shopping cart system that has selectable options via radio button, so the buttons look like so:
<input type="radio" name="option[218]" value="5">
<input type="radio" name="option[218]" value="6">
<input type="radio" name="option[218]" value="7">
...
The section of the jQuery script that's throwing the error looks like so:
$('input:radio[name=' + radio.attr('name') + ']')
.not(':disabled')
...
Error:
Uncaught Error: Syntax error, unrecognized expression: input:radio[name=option[218]]
Obviously it's not expecting to find brackets [ ] in the name value.
How can I switch this up to allow those to be found and not error out?