i have a JavaScript program that make input and a want to remove spell check.
let inp = document.createElement('input');
inp.placeholder = "enter line of code";
inp.autocomplete = "off";
//did not work
inp.spellcheck = "false";
i tried using inp.spellcheck = "false";
and it did not work
however just spellcheck="false" on a input worked
CodePudding user response:
If you work with the JavaScript DOM spellcheck
property (as opposed to the HTML spellcheck
attribute), you need to assign an actual boolean value, not a string.
const inp = document.body.appendChild(document.createElement('input'));
inp.placeholder = "enter line of code";
inp.autocomplete = "off";
inp.spellcheck = false; // not "false" which is a string
CodePudding user response:
Set an attribute instead.
const inp = document.body.appendChild(document.createElement('input'));
inp.placeholder = "enter line of code";
inp.autocomplete = "off";
inp.setAttribute('spellcheck', 'false');