Files
to-hen/ocaml/main.ml

24 lines
510 B
OCaml
Raw Permalink Normal View History

2026-03-14 07:05:56 +01:00
open Js_of_ocaml
(* open Js_of_ocaml.Dom_html *)
let document = Dom_html.document
let by_id id =
Js.Opt.get
(document##getElementById (Js.string id))
(fun () -> failwith ("Missing element: " ^ id))
let () =
let button = by_id "btn" in
let output = by_id "output" in
let clicks = ref 0 in
button##.onclick :=
Dom_html.handler (fun _ ->
incr clicks;
output##.textContent :=
Js.some (Js.string ("Clicked " ^ string_of_int !clicks ^ " times"));
Js._false
)