Last Updated: February 25, 2016
·
379
· nicooga

Grammar check on static pages (Using Chrome)

Have you ever had to check the grammar on a static page? I know Chrome has spellchecking, but it doesn't affect non editable stuff like ps and h1s and etc.

So what know? This is what I did. Open your page on Chrome and hit the secret suquence ctrl+shift+J.

Then make all stuff editable and enable spellchecking!

$('p, h1, h2, h3, h4, h5, h6, a, button, ETC')
 .attr('spellcheck', 'true')
 .attr('contenteditable', 'true')

Or with plain JS:

var tag_names = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'];

for (var x in tag_names) {
  var tag_name = tag_names[x];
  var elements = document.getElementsByTagName(tag_name);

  for (var x1 in elements) {
    var element = elements[x1]
    element.setAttribute('spellcheck', 'true');
    element.setAttribute('contenteditable', 'true');
  }
}