Does anyone know how to escape the square bracket character when setting a class name with jQuery?
Try the following:
$(\'#txtFirstname\').addClass(\
The introduction of jQuery API page gives the above explanation about this:
To use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[]^`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \\.