Platform
Resources
Pricing
Sign in
Get started
Andrew Wooldridge
📜JavaScript developer. 🐲RPG fan. 📚Storyteller and 🕹game developer. 👨Father and Husband.
Workspace
Fork
Published
3 collections
By
Andrew Wooldridge
Edited
Oct 12, 2021
1 star
JavaScript Tips
String.prototype.replaceAll
How To Use Local JS Files in Your Notebooks
Import JavaScript Class from Github Gist
Hello, sortablejs
Hello, JS-YAML
Testing bitECS for Tempest
New Options for Images in Observable
Test Message Channel
JavaScript Class Exploration
How To: Create and Update HTML Views
How to: filter a data set via search + suggestions
How to Center a Div
Run Some Code on Button Click
Using JSON Placeholder
Scrubber Test
Executable JS FileAttachment Test
Hello, Handel
Data from Google Spreadsheets test 001
Testing fetch with runkit
Testing ecsyjs
Move a Div in JavaScript
Also listed in…
Tips and Utilities
HTML Elements
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
output
=
html
`<div>Like <strong>this</strong></div>`
Insert cell
Using the
<
b
>
HTML
</
b
>
cell type
Insert cell
Using the
**
Markdown
**
cell type
Insert cell
{
let
foo
=
document
.
createElement
(
"div"
)
;
foo
.
innerHTML
=
"Via native <b>JavaScript</b>"
return
foo
;
}
Insert cell
Insert cell
Insert cell
{
// create a HTML block
const
out
=
html
`<div>Some HTML: <span></span></div>`
// then yield it
yield
out
;
// you can then manipulate it
out
.
querySelector
(
"span"
)
.
innerHTML
=
"<b>(Added later)</b>"
// note out is a local variable here.
}
Insert cell
Insert cell
{
const
out
=
html
`<span>The value is ${
range
}`
yield
out
;
}
Insert cell
Move the slider to see the value change in HTML
Insert cell
viewof
range
=
Inputs
.
range
(
[
0
,
100
]
,
{
label
:
"Amount"
}
)
Insert cell
Insert cell
<
div
class
=
"myClass"
>
Hey, I'm some HTML!
</
div
>
Insert cell
html
`<style>
.myClass {
background-color: ${
color
};
padding: 8px;
}
</style>`
Insert cell
Insert cell
Insert cell
Insert cell
<
style
>
div
{
font-family
:
sans-serif
;
}
</
style
>
Insert cell
Insert cell
Insert cell
added
=
"I got added"
// each var it's own cell
Insert cell
{
const
out
=
html
`<div><b>${
added
}</b></div>`
;
yield
out
;
}
Insert cell
###
DOM Poke Way
Insert cell
{
const
out
=
html
`<div><b></b></div>`
;
yield
out
;
out
.
querySelector
(
"b"
)
.
appendChild
(
html
`<i>I got added</i>`
)
}
Insert cell
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.
Try it for free
Learn more
Fork
View
Export
Listed in...
Tips and Utilities
Andrew Wooldridge
HTML Elements
Andrew Wooldridge
JavaScript Tips
Andrew Wooldridge
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
output
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
range
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
color
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
added
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML