HTML onfocus event properties
Examples
Run the script when the field gets focus:
<input type="text" id="fname" onfocus="setStyle(this.id)">
try it"
Browser Support
All major browsers support onfocus event attributes
Definition and Usage
onfocus attribute triggered when the element gets focus
Onfocus usually used <input>, <select>, and <a> elements.
Tip: onfocus attribute opposite property event the onblur .
Note: onfocus attribute can not be used on the following elements: <base>, <bdo> , <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, or <title>.
Differences between HTML 4.01 and HTML5
no.
grammar
<Elementonfocus = "script">
Property Value
值 | 描述 |
---|---|
script | 规定该onfocus事件触发时执行的脚本 |
HTML Event Attributes