How to attach OCaml values to DOM elements?

It is often convenient to attach OCaml values to some elements of the page. There are several ways to do that.