Your error says that there is no element that matches your selector, so element.val() returns undefined that does not have a replace method. Try debugging it and console.log() at each step.
In addition, you do not need to search for an item twice. Just save it in a variable:
var $input = $(this).find('input[name="amount"]'); $input.val($input.val().replace('$', ''));
source share