Giving an input element focus when the page loads

I want an input element to have focus when the page loads. The following code simply gives the element a black border - it still has to be clicked before it can be typed in to.

$w.onReady(function () {
$w(‘#input3’).focus()
})

The documentation says that this code is equivalent to a mouse click in the element. However, a click is still needed before it can be typed in to.

Hey, select the input3, go to the properties panel and choose the event onViewPortEnter and inside that function you enter your focus(); method. I did this in some cases it works and on some mobile devices it doesn’t

1 Like

Thank you

1 Like