removed event.preventDefault(); as it was giving an error in JS in Firefox.