The reason the button is being removed is because the current selector runs that each
for the hidden inputs right before the button as well as the radio buttons. I assume you only want to be executing this for the radio buttons. The label.remove();
line removes the input button when it runs on the hidden input right before it.
The $('input').each(function(){
is running for every input, not only the radio buttons. If you want to restrict it to those, change your selector to $('input[type="radio"]').each(function(){