正文
jquery设置readonly,jquery设置input的value值
小程序:扫一扫查出行
【扫一扫了解最新限行尾号】
复制小程序
【扫一扫了解最新限行尾号】
复制小程序
jquery中怎么获取页面input并且readonly属性input元素对象?
在“jquery”中取“input的readonly”属性时,发现“:$(“#input”).readonly”取这个属性时,总是“undefined”,难道“html”中的属性“only”没有大写,是不是“javascript”需要将O大写。
修改之后“$(“#input”).readOnly”,就能取到值。“Javascript: ”为input设置“readOnly”属性。
使用“javascript” 动态设置“textbox的readonly”,发现 “readonly ”属性为:“readOnly=true”(注意,javascript 的大小写)。
input只读属性有两种方式可以实现input的只读效果:“disabled” 和“ readonly”。“Disabled”说明该input无效,及其value不会传递给任何程序,比如asp、php等。“Readonly”仅仅是无法编辑,不影响其值的传递。
“Disabled”使用:“INPUTtype=”text”name=”
username”value=”james”disabled”。
“Readonly”使用:“INPUT type=”text” name=”partNumber”value=”1500″ readonly”。
如何设置多个文本框只读 jquery
添加同个类,设置readonly属性;如:
HTML:
input type="text" class="textBox" /
input type="text" class="textBox" /
input type="text" class="textBox" /
input type="text" class="textBox" /
JQ:
$(document).ready(function(){
$(".textBox").attr("readonly","readonly");
});
如何用jquery动态改变输入框的readonly属性
$('input[name=username]').attr("readonly","readonly")//将input元素设置为readonly
$('input[name=username]').removeAttr("readonly");//去除input元素的readonly属性
jquery如何让所有表单元素均为只读
1、在1.6版本之前的使用
$('input,select,textarea',$('form[name="my_form"]')).attr('readonly',true);
2、如果较老的就使用:$('input,select,textarea',$('form[name="my_form"]')).prop('readonly',true);
3、$('form').find('input,textarea,select').not('这里代表需要改的元素的查找').attr('readonly',true) 或者使用 prop('readonly',true).