教程集 www.jiaochengji.com
教程集 >  jQuery  >  jquery 教程  >  正文 html组件不可输入(只读)同时任何组件都有效

html组件不可输入(只读)同时任何组件都有效

发布时间:2013-11-30   编辑:jiaochengji.com
在开发过程中经常会碰到让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组件不可输入(只读)同时任何组件都有效
转载:用Visual C#动态生成组件,请看!(二)
学习php读取文件内容的方法
PHP 文件系统详解(推荐)
vbscript基础教程-数组
浅谈PHP组件、框架以及Composer
ASP.NET 2.0服务器控件开发
php 目录与文件处理的方法
利用PHP和AJAX创建RSS聚合器(一)
php文件操作常用函数汇总

关键词: html组件  不可输入  只读   
[关闭]
~ ~