Public
Edited
Jan 16, 2023
Paused
28 stars
Insert cell
Insert cell
Insert cell
myName = "Fabian"
Insert cell
myName
Insert cell
Insert cell
myName2 = htl.html`<input type="text" value="Fabian">`
Insert cell
Insert cell
myName2
Insert cell
Insert cell
myName2.value
Insert cell
Insert cell
Insert cell
viewof myName3 = htl.html`<input type="text" value="Fabian">`
Insert cell
viewof myName3
Insert cell
myName3
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof word_of_the_day = {
// The parent element, on which we'll set the value.
const myView = htl.html`<p>`;
for(const word of ["The", "bird", "is", "the", "word"]) {
const style = 'cursor: pointer; border: 2px solid #50f5; margin: .1em';
const clickableWord = htl.html`<strong style="${style}"> ${word} </strong>`;
myView.appendChild(clickableWord);
clickableWord.onclick = () => {
// Set the new value:
myView.value = word;
// This tells Observable that the value has changed:
myView.dispatchEvent(new Event("input", {bubbles: true}));
};
}
return myView;
}
Insert cell
Insert cell
word_of_the_day
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