I have the following input fields in a form. I would like remove undefined and replace it with a blank space "". I can't seem to get it to work. I only would like to remove "undefined" not original value.
<input type="hidden" name="address1" id="address1" value="Some address undefined" class="address1">
<input type="hidden" name="address2" id="address2" value="Another address undefined" class="address1">
I would only like to remove undefined. So far I've tried:
var str = $('input').value().replace(/undefined/g, 'ada');
$('input').value(str);
and
$('input:contains("undefined")').each(function(){
$(this).html($(this).html().split("undefined").join(""));
});