<p>A simple example of the live sample system in action.</p>
<div class="box">
<div id="item">Hello world! Welcome to MDN</div>
</div>Live samples (EmbedLiveSample) / notebook
Live samples (EmbedLiveSample)
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
.box {
width: 200px;
border-radius: 6px;
padding: 20px;
background-color: #ffaabb;
}
#item {
font-weight: bold;
text-align: center;
font-family: sans-serif;
font-size: 1.5em;
}const el = document.getElementById("item");
let toggleClick = false;
el.onclick = function () {
this.textContent = toggleClick
? "Hello world! Welcome to MDN"
: "Owww, stop poking me!";
toggleClick = !toggleClick;
};