Html 输入文本元素的正确只读属性语法是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16109358/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the correct readonly attribute syntax for input text elements?
提问by Obmerk Kronen
As Most, I am familiar with the readonly
attribute for text input
, But while reading code from other websites (a nasty habit of mine ) I saw more than one implementation for this attribute:
与大多数人一样,我熟悉readonly
for的属性text input
,但是在阅读其他网站的代码时(我的一个坏习惯),我看到了此属性的多个实现:
<input type="text" value="myvalue" class="class anotherclass" readonly >
and
和
<input type="text" value="myvalue" class="class anotherclass" readonly="readonly" >
and I have even seen
我什至见过
<input type="text" value="myvalue" class="class anotherclass" readonly="true" >
.. And I believe I saw even more, but can not recall the exact syntax now..
.. 我相信我看到了更多,但现在想不起来确切的语法了..
So, which one is the correct one that I should use?
那么,我应该使用哪一种是正确的呢?
回答by Vucko
回答by billah77
is should be
应该是
<input type="text" value="myvalue" class="class anotherclass" readonly="readonly" />