htmlFor property (script)
Sets or retrieves the identifier of the element to which the script is bound when a specific event is fired for the element.
Use it together with the event property that specifies the type of the event to listen for. For a cross-browser solution use inline event attributes. See Example 2 for details.
You can find the related objects in the Supported by objects section below.
This property is read/write.
|HTML page for this property: for|
String that sets or retrieves the identifier of an element.
Default: this property has no default value.
Example HTML code 1:
This example illustrates the use of the for attribute:
Example HTML code 2:
This example is equivalent to the previous one, but it uses inline event handling to listen for the event:
Example HTML code 3:
This example illustrates the use of the for attribute and the htmlFor property:
User Contributed Comments