I'm trying to use this to clean up my select options as they come in from AJAX. Many of them have an "_" in them and I want to remove them:
$.each(data, function(i, data) {
$('#first_select2').append("<option>" + data.COLUMN_NAME + "</option>");
$('#first_select2').replace(/_/g, " ");
});
The replace works fine if I try to use it outside of an each. If I use it in the .each, I get this error:
Uncaught TypeError: undefined is not a function
Is there a way to do what I need here?
_indata.COLUMN_NAME? if so, do it before you append.$('#first_select2')<-- This is a jQuery object but.replace(/_/g, " ")<-- "replace" works on strings.