Spellcheck disable with CSS not HTML

前端 未结 2 798
广开言路
广开言路 2021-01-04 00:31

I want to disable spellchecking in Chrome/Safari using CSS. In HTML spellcheck=\"false\" works but I want to do this in a way that will affect all input fields.

相关标签:
2条回答
  • 2021-01-04 00:35

    use jQuery. Something like:

    $(document).ready( function() {
        $("input[type='text'], textarea").attr('spellcheck',false);
    });
    

    This should search for all textbox's and teatarea's on the page and add the attribute spellcheck="false" to them.

    0 讨论(0)
  • 2021-01-04 00:37

    This does not belong to the realm of CSS (which is optional presentational suggestions). It is not about stylistic features of rendering data but about processing data interactively.

    On browsers that support “spell checking” (which may involve grammar and style checks), the HTML attribute spellcheck or the corresponding IDL (DOM) attribute, settable in JavaScript, is effective.

    In practice, those browsers tend to have “spelling checking” enabled by default for textareas only, and as textareas normally contain human language texts, turning it off does not sound useful. It is in any case user-controllable (the user can switch it off or select language).

    0 讨论(0)
提交回复
热议问题