欢迎您访问我爱IT技术网,今天小编为你分享的javascript教程:【html组件不可输入(只读)同时任何组件都有效】,下面是详细的讲解!
html组件不可输入(只读)同时任何组件都有效
var setReadOnly=function()
{
var input=$("input");
input.each(function(i)
{
$(this).attr("onfocus", "this.blur();return false;");
$(this).wrap(function()
{
return '<span onmousemove="this.setCapture();" onmouseout="this.releaseCapture();" />';
});
});
var select=$("select");
select.each(function(i)
{
$(this).attr("onfocus", "this.blur();return false;");
$(this).wrap(function()
{
return '<span onmousemove="this.setCapture();" onmouseout="this.releaseCapture();" />';
});
});
var textarea=$("textarea");
textarea.each(function(i)
{
$(this).attr("onfocus", "this.blur();return false;");
$(this).wrap(function()
{
return '<span onmousemove="this.setCapture();" onmouseout="this.releaseCapture();" />';
});
});
var img=$("img");
img.each(function(i)
{
$(this).attr("onfocus", "this.blur();return false;");
$(this).wrap(function()
{
return '<span onmousemove="this.setCapture();" onmouseout="this.releaseCapture();" />';
});
});
}
关于html组件不可输入(只读)同时任何组件都有效的用户互动如下:
相关问题:html文本框不可编辑,禁止用户修改的几种方法
答:具体步骤: 方法一:设置readonly属性为true。 Html代码 1. 方法二:设置disabled属性为true。 Html代码 1. 方法三:在对象focus时立刻让它blur,使它无法获得焦点。 Html代码 1. 提示:readonly和disabled的区别在于后者完全禁止与设置该属性的... >>详细
相关问题:求教限制<input>输入框不能输入任何东西的html代码...
答: value="联系人" 这个是设初始值为联系人 onClick="if (this.value=='联系人'){this.value=''}" 点击后,清空输入框。 >>详细
相关问题:如何让 HTML 控件只读或不可用
答:利用 HTML 利用 XHTML 利用 JavaScript >>详细
- 【firefox】firefox浏览器不支持innerText的解决
- 【Extjs】Extjs学习过程中新手容易碰到的低级错误
- 【clearInterval】js clearInterval()方法的定义
- 【ComboBox】ComboBox 和 DateField 在IE下消失的
- 【dom】javascript dom追加内容实现示例-追加内容
- 【checkbox】让checkbox不选中即将选中的checkbox
- 【Array】js中更短的 Array 类型转换-类型转换
- 【append】append和appendTo的区别以及appendChil
- 【ExtJs】ExtJs 表单提交登陆实现代码-表单提交-
- 【ajax清除浏览器缓存】Ajax清除浏览器js、css、
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
