html5的spellcheck属性(拼写、文法检查)

html5的spellcheck属性

<!DOCTYPE html> 
<html> 
<head> 
<meta charset="utf-8" /> 
<title>spellcheck属性的使用</title> 
</head> 
<body> 
<style>
.ac{border:1px solid #ff7300;width:200px;height:100px;}
</style>
<pre>
1.<b>输入完某个单词后,进行按空格键,就可以看到这是不是错误的单词了。</b>
2.spellcheck="true"、'false'、"",值为true和""时,代表检查。。
【空字符串为什么检查:就跟input其他属性一样,你设置个readonly就是只读( readonly=""),再加个值描述的更准确。】
3.使用场合:
   1.类型为text型的input元素,但input类型为text型的input元素,但input="password"不行(原因:你是密码哎,都是星号还检查个啥玩意,密码本身就是不同字母组合而出的)。
   2.textarea元素
   3.spellcheck属性,html5中的所有元素都可以指定,对于不是输入栏的元素,须指定contenteditable="true" 编辑属性,才能使用。(如div什么的。)
4.现代浏览器都支持以及IE10   
</pre>

<p>检测<textarea spellcheck="true" >absolute testK</textarea> </p> 
<p>不检测 <textarea spellcheck="false"></textarea> </p> 
<div contenteditable="true" spellcheck class="ac">div absolute testK</div>
<p>readonly="":<input readonly=""/></p>
<p><input type="password" spellcheck="true"/></p>
</body> 
</html>

  (文章来自转载)

posted @ 2018-07-10 19:47  阿力瓦  阅读(2989)  评论(0编辑  收藏  举报