Ⅰ 如何用javascript代码控制input标签的readonly或disabled属性
我喜欢用JQuery的attr()方法,超方便,也强大。
比如:(前提是先引入JQuery)
<input type="button" class="button" />
$(".button").attr("disabled","disabled");
当然,你也可以使用原生js来写,跟楼上的差不多,其实都一样,看你喜欢吧。不过我不喜欢用ID来限制DOM元素,因为有很多时候如果你不清楚CSS的优先级的话,会出现很多麻烦,用ID来限制元素优先级很高的,不过那是另外别的问题了跟你这没关系
Ⅱ js去除 html 中 input 的readOnly属性
<inputtype="text"readonlyid=aa>
<inputtype=buttononclick="document.all.aa.readOnly=false"value="input">

拓展资料:
readonly 属性规定输入字段为只读。只读字段是不能修改的。不过,用户仍然可以使用 tab 键切换到该字段,还可以选中或拷贝其文本。readonly 属性可以防止用户对值进行修改,直到满足某些条件为止(比如选中了一个复选框)。然后,需要使用 JavaScript 消除 readonly 值,将输入字段切换到可编辑状态。readonly 属性可与 <input type="text"> 或 <input type="password"> 配合使用。
Ⅲ 关于JS如何实现表单的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.
Ⅳ js控制readonly只读为什么onblur还会执行,怎么让他不执行
写一句
obj.onblur=function(){return false;};
这样onblur后什么都不执行就可以了
Ⅳ js readonly 怎么控制输入框内的可读不可读,想让一个不可读输入框中的内容在点击相应按钮的情况下改为可
这样:
<script>function doclick1(){
var txtN = document.getElementById("contactus5");
txtN.readOnly = false;
}
</script>
<input type="text" id="contactus5" readonly>
<input type="button" name="button4" value="修改" onclick="doclick1();" />
Ⅵ 关于javascript中readonly的问题
readonly是这标签个的一个属性说明这个文本框只能读不能编辑,"/>"是html中的标签结束标志
Ⅶ 如何用Javascript代码控制input标签的readonly或disabled属性
<input type="text" id="Cs" value="123" />
<script type="text/javascript">
var Js_Cs= document.getElementById("Cs");
Js_Cs.readOnly=true;
</script>
PS:此时JavaScript代码要写到<input>;