javascript onfocus attribute
Translation results:
on
UK[ɒn] 美[ɑ:n]
prep. (indicates direction) to; (indicates object) to; ( Indicates position) on...; (indicates time) at the time of...
adv. (put, wear, connect) on; forward, (continue) down
adj. active Situation, status; being used; happening; planned
focus
UK[ˈfəʊkəs] US[ˈfoʊkəs]
vt. & vi. (to) concentrate, (to) gather; adjust (lens, eye) focus [focal length] in order to see clearly
vt. Adjust (eye or lens) focal length; concentrate (beam on); focus , gaze; concentrate
n. focus; clarity of image; center (of activity, attention, interest, etc.); [medical] focus, illness
Third person singular: focuses Plural: foci Present participle: focusing Past tense: focused Past participle: focused
javascript onfocus attributesyntax
Function: Occurs when the object gains focus.
Syntax: onfocus="SomeJavaScriptCode"
Parameters: SomeJavaScriptCode Required. Specifies the JavaScript to be executed when this event occurs.
javascript onfocus attributeexample
<html> <head> <script type="text/javascript"> function setStyle(x) { document.getElementById(x).style.background="yellow" } </script> </head> <body> First name: <input type="text" onfocus="setStyle(this.id)" id="fname"> <br /> Last name: <input type="text" onfocus="setStyle(this.id)" id="lname"> </body> </html>
Run instance »
Click the "Run instance" button to view the online instance