×

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

作者:前端菜鸟2018.02.23来源:Web前端之家浏览:8813评论:0
关键词:JQueryJS

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();" />'; 
}); 
}); 
}

您的支持是我们创作的动力!
温馨提示:本文作者系 ,经Web前端之家编辑修改或补充,转载请注明出处和本文链接:
https://www.jiangweishan.com/article/svg1488211200500.html

网友评论文明上网理性发言 已有0人参与

发表评论: