在JS中ReadOnly属性比较奇怪,直接创建一个对象,给该对象赋值readonly属性不能够向HTML中一样使用下面的方式: var x = document.createElement( " input " );x.type = " text " ;x.value = " ttttt " ;x.id = " xy " ;x.readonly = " readonly " ; 这样创建的对象并不是只读的。正确的写法是: var x = document.createElement( " input " );x.type = " text " ;x.value = " ttttt " ;x.id = " xy " ;x.readOnly = true ; 这个平时写JS时候要注意。