Skip to content

Instantly share code, notes, and snippets.

@shu8
Created November 30, 2014 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shu8/a1e652178ff4483c5c9d to your computer and use it in GitHub Desktop.
Save shu8/a1e652178ff4483c5c9d to your computer and use it in GitHub Desktop.
function addButtonBefore(inputItem) {
var button = document.createElement("button");
var text = document.createTextNode("disable/enable spellcheck");
button.appendChild(text);
cssString = "font-size: 9px; border: 0; border-radius: 10px; outline: none; color: inherit;"
button.style.cssText = cssString;
button.setAttribute("title", "disable/enable spellcheck")
button.addEventListener('click', function(e) {
inputItem.spellcheck = !inputItem.spellcheck;
e.preventDefault();
e.stopPropagation();
e.cancelBubble = true;
e.returnValue = false;
return false;
});
inputItem.parentNode.insertBefore(button, inputItem.nextElementSibling);
}
Array.prototype.forEach.call(document.getElementsByTagName('textarea'), function(inputItem) {
addButtonBefore(inputItem);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment