首页 >web前端 >js教程 >html组件不可输入(只读)同时任何组件都有效_jquery

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原创
2016-05-16 17:38:511279浏览
复制代码如下代码:

/**
* 将页面设置为只读
*/
var setReadOnly = function ()
{
var input = $("input");
input.each(function(i)
{
$(this).attr("onfocus", "this.blur();return false;");
$(this). wrap(function()
{
return '';
}); >});
var select = $("select");
select.each(function(i)
{
$(this).attr("onfocus", "this.blur();return false;");
$(this). wrap(function()
{
return '';
}); >});
var textarea = $("textarea");
textarea.each(function(i)
{
$(this).attr("onfocus", "this.blur();return false;");
$(this). wrap(function()
{
return '';
}); >});
var img = $("img");
img.each(function(i)
{
$(this).attr("onfocus", "this.blur();return false;");
$(this). wrap(function()
{
return '';
}); >});
}

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn