Reputation: 2639
Is there a way to automatically escape characters in a jQuery variable? My variable looks like this:
var $name = $(this).prev().attr('name');
Things get hairy now because the name has square brackets. So when I try to do this:
$('input:radio[name='+$name+']').next().addClass('so_pretty');
javascript throws a fit because it gets confused from all the brackets.
Anyway to add those escape slashes on the fly?
Thanks, Leo
Upvotes: 3
Views: 1619