package fmlib_js

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Element node.

type t

Type of an element node.

val node : t -> Node.t

Element viewed as a node. All elements are nodes, therefore no conversion is necessary.

val scroll_width : t -> int

Width of the element, including content not visible due to overflow.

It includes padding, but not the border and margins.

val scroll_height : t -> int

Height of the element, including content not visible due to overflow. It includes padding, but not margin and border.

val client_width : t -> int

Width of the visible part of the element with padding, without border and margins.

val client_height : t -> int

Height of the visible part of the element. It includes padding, but not margins, border and scrollbars.

val scroll_left : t -> int

Number of pixels the element's content is scrolled from its left edge.

val scroll_top : t -> int

Number of pixels the element's content is scrolled vertically.

val set_scroll_left : int -> t -> unit

set_scroll_left pxs element Set the left scroll position to pxs.

val set_scroll_top : int -> t -> unit

set_scroll_top pxs element Set the top scroll position to pxs.

val style : t -> Style.t

Style attribute of the element.

val set_attribute : string -> string -> t -> unit

set_attribute name value element Set the attribute name to value on element.

Examples:

set_attribute "id"    "my-node"  element
set_attribute "class" "my-class" element
set_attribute "href"  "https://github.com" element
set_attribute "type"  "range"    element
set_attribute "type"  "password" element
set_attribute "placeholder" "sample-text" element
val remove_attribute : string -> t -> unit

remove_attribute name element Remove the attribute name from element.

val set_property : string -> Base.Value.t -> t -> unit

set_property name value element Set the property name to value in element.

The distinction between attributes and properties is subtle. Attribute have always a string value and implicitely set the corresponding property as well. A property can have any javascript value and does not set the corresponding attribute, even if the property has a string value.

Examples:

set_property "value" "my-text" input_element
val delete_property : string -> t -> unit

delete_property name element Delete the property name from element.

val focus : t -> unit

Put the element into keyboard focus.

val blur : t -> unit

Unfocus the element.

OCaml

Innovation. Community. Security.