What is the difference between readonly=“true” & readonly=“readonly”?

What is the difference between readonly=“true” & readonly=“readonly”?

What is the difference between:

<input name="TextBox1" type="text" id="TextBox1" readonly="true" />

and:

<input name="TextBox1" type="text" id="TextBox1" readonly="readonly" />

When i set readonly to true it works somewhat different from readonly='readonly'. W3C standard says readonly should be 'readonly' & not 'true'. Why most of the browsers allow readonly='true' which has somewhat different functionality than readonly='readonly'?

回答

Giving an element the attribute readonly will give that element the readonly status. It doesn't matter what value you put after it or if you put any value after it, it will still see it as readonly. Putting readonly="false" won't work.

Suggested is to use the W3C standard, which is readonly="readonly".

原文地址:https://www.cnblogs.com/chucklu/p/14202914.html