Is it possible to disable spellcheck in a textarea via JavaScript?
I've been looking at the HTML5 'spellcheck' attribute, and I can get it to work on its own. However, I'd like to be able to change this attribute via JavaScript.
After reading the documentation provided at the above link, I put together the following lines of code (snippets from a larger file; I know they won't work on their own):
document.querySelector("#editor").spellcheck = "false";
and
document.querySelector("#editor").spellcheck = "true";
But it doesn't seem to work. Have I made a mistake or misunderstood the documentation? (Unhelpfully, the JavaScript console in Google Chrome is not returning an error.) Or is there any other way to go about doing this?
You are setting it to the String "true"
(which is a true
value) and to the String "false"
(which is also a true
value).
Use Booleans, not Strings. Get rid of the quotes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With