/    Sign up×
Community /Pin to ProfileBookmark

Focus on a field when loaded

Hi,

I would like to automatically have the focus on a particular form element when my HTML page loads, but am not sure how to do this. Is there a particular keyword like FOCUS or something that allows a programmer to specify what field should have the default focus?

I don’t really know where to begin looking for this and would really appreciate it if anyone could head me in the right direction! ?

Thanks in advance,
Jill

to post a comment
HTML

1 Comments(s)

Copy linkTweet thisAlerts:
@steelersfan88Oct 14.2004 — You will probably have to use JS for this, but you might want to look into the [url=http://www.w3.org/TR/REC-html40/interact/forms.html#adef-tabindex]tabindex[/url] attribute (if an input object).<script type="text/javascript">
onload = function() {
document.getElementById('elem').focus();
}
</script>
×

Success!

Help @Jills2000 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...