Accessibility: By clicking on button move the focus to the input

Accessibility: By clicking on button move the focus to the input

Hi,

Looking at my example here (sorry for the messy code, only the jQuery part is relevant):


I want to achieve that when I click on "Register" button, the focus move from the button to the input field "First Name".

But it doesn't work with the first click. It works only if I click a second time on the "Register" button.

Why is that? How can I fix this?

Thanks