Published
Edited
Apr 8, 2020
28 stars
Insert cell
Insert cell
names = ["Alice", "Bob", "Carlos"]
Insert cell
html`<ul>${names.map(name => html`
<li>My name is ${name}!</li>
`)}</ul>`
Insert cell
Insert cell
function click(name) {
input.value = name;
}
Insert cell
input = html`<input type=text readonly>`
Insert cell
Insert cell
html`<ul>${names.map(name => html`
<li>My name is ${name}! <a href="#" onclick=${() => click(name)}>Pick me.</a></li>
`)}</ul>`
Insert cell
htl = require("htl@0.2")
Insert cell
html = htl.html
Insert cell
Insert cell
html`<ul>${names.map(name => html`
<li>My name is ${name}! ${Object.assign(html`<a href="#">Pick me.</a>`, {onclick() { click(name)}})}</li>
`)}</ul>`
Insert cell
Insert cell
d3.create("ul")
.call(ul => ul.selectAll("li")
.data(names)
.join("li")
.text(name => `My name is ${name}! `)
.append("a")
.attr("href", "#")
.on("click", click)
.text("Pick me."))
.node()
Insert cell
d3 = require("d3-selection@1")
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more