You have to stop the propagation of the event that the clicked button is triggering.
So, the right code is this:
$("input").click(function(e)
{
e.preventDefault();
e.stopPropagation();
$("#button").trigger('click');
});