<div>
<span id="sc-label">The spelling and grammar may be checked: </span>
<span id="sc-element" contenteditable="true" spellcheck="true">test</span>
</div>
<input id="sc-controller" type="checkbox" checked />Enable spelling and grammar
checkHTMLElement: spellcheck property / notebook
HTMLElement: spellcheck property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const label = document.getElementById("sc-label");
const element = document.getElementById("sc-element");
const controller = document.getElementById("sc-controller");
controller.addEventListener("change", (e) => {
if (controller.checked) {
element.spellcheck = true;
label.innerText = "The spelling and grammar may be checked: ";
} else {
element.spellcheck = false;
label.innerText = "The spelling and grammar may not be checked: ";
}
});