I have a value like this
<option value="RB+TE+WR+DEF+CB">text</option>
I'm trying to replace all instances of "+" with a "-"
Both my tries only replaced the 1st "+" and results were
<option value="RB-TE+WR+DEF+CB">text</option>
This is what i've tried
$('option').each(function () {
$(this).val(function (i, v) {
return v.replace("+", "-");
});
})
$('option').val(function (i, v) {
return v.replace("+", "-");
});
$('option').val(function (i, v) {
return v.replace(new RegExp("/+/", "g"), '-');
});
I need the result to be
<option value="RB-TE-WR-DEF-CB">text</option>