如何在javascript里设置表单为只读属性
2个回答
展开全部
你是要设置表单的什么元素为只读?如果是text或textarea,加一个参数readonly就行了
追问
喔喔太感谢了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
function check(){
var txtN = document.getElementById("test");
txtN.setAttribute("readonly",true,0);
}
setAttribute 这个方法一定要注意,有三个参数
object.setAttribute(sName, vValue [, iFlags])
last arg
iFlags: Optional. Integer that specifies one the following flags: 0 When the attribute is set, it overwrites any attributes with the same name, regardless of their case.
1 Default. The case of the attribute that you set is respected when it is set on the object.
var txtN = document.getElementById("test");
txtN.setAttribute("readonly",true,0);
}
setAttribute 这个方法一定要注意,有三个参数
object.setAttribute(sName, vValue [, iFlags])
last arg
iFlags: Optional. Integer that specifies one the following flags: 0 When the attribute is set, it overwrites any attributes with the same name, regardless of their case.
1 Default. The case of the attribute that you set is respected when it is set on the object.
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询