I currently have a series links that open menus containing dropdowns and input textboxes to add new options to the dropdowns:

If I save a value containing no spaces (“hello”), everything works fine, but if a value contains spaces (“hello 2”), I get an exception that says ‘Uncaught Error: Syntax error, unrecognized expression: [value=hello 2]’
These are the two approaches that I’ve tried so far that have been unsuccessful:
$('.addSetSelect').append('<option value="' + setName + '">' + setName + '</option>');
and
$('.addSetSelect').append(new Option(setName, setName));
I was wondering what is the best way to go about adding option elements to a selectbox that can contain value attributes with spaces?
You’re probably just running into string concat problems. This is more fool proof: