Basically rather than writing the function twice we can use .each and have it apply to all available inputs. By using .each jQuery loops through each input and apply the function individually, so default_value = $(this).val() will be the value of a specific input.