html组件不可输入(只读)同时任何组件都有效
更新时间:2013年04月01日 09:05:34 作者:
在开发过程中经常会碰到让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();" />';
});
});
}
您可能感兴趣的文章:
相关文章
使用jQuery mobile库检测url绝对地址和相对地址的方法
这篇文章主要介绍了使用jQuery mobile库监测绝对地址和相对地址的方法,分别是isAbsoluteUrl()和isRelativeUrl()方法的使用,需要的朋友可以参考下2015-12-12
jQuery实现鼠标滑向当前图片高亮显示并且其它图片变灰的方法
这篇文章主要介绍了jQuery实现鼠标滑向当前图片高亮显示并且其它图片变灰的方法,涉及jquery链式操作及页面元素样式控制的相关技巧,需要的朋友可以参考下2015-07-07


最新评论