/    Sign up×
Community /Pin to ProfileBookmark

I need a quick javascript.

I have a link, lets say its like this:

[CODE]<a href=”#” OnMouseOver=””>Set Focus</a>[/CODE]

and i have a input:

[CODE]<input type=”text” id=”ProfileSearch”>[/CODE]

I need a js so that when the user mouseovers the link it sets focus to the input.

I would prefer it to be like onMouseOver=”javascript: ___” or “ProfileSearch.focus()”

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@ricpMar 17.2007 — for a start you would never do... onevent="javascript: __ " ..the script protocol is not needed.

<i>
</i>&lt;a href="#" onmouseover="document.getElementById('ProfileSearch').focus()"&gt;Set Focus&lt;/a&gt;
&lt;input type="text" id="ProfileSearch"&gt;

That'll do what you asked for. I am a little uneasy using that code as the <a> tag is really meant for navigation, not setting focus. With that in mind I would change it to a <span> or something similar.
×

Success!

Help @Tabo 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.28,
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,
)...