html組件不可輸入(只讀)同時任何組件都有效
更新時間:2013年04月01日 09:05:34 作者:
在開發(fā)過程中經(jīng)常會碰到讓html組件不可輸入(只讀),任何組件都有效的情況,接下來將為大家詳細實現(xiàn)下,感興趣的朋友可以參考下哈
復制代碼 代碼如下:
/**
* 將頁面設置為只讀
*/
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 Ajax 學習實例2 向頁面發(fā)出請求 返回JSon格式數(shù)據(jù)
處理業(yè)務數(shù)據(jù),產生JSon數(shù)據(jù),供JqueryRequest.aspx調用2010-03-03jqueryMobile 動態(tài)添加元素,展示刷新視圖的實現(xiàn)方法
下面小編就為大家?guī)硪黄猨queryMobile 動態(tài)添加元素,展示刷新視圖的實現(xiàn)方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-05-05jquery.uploadify插件在chrome瀏覽器頻繁崩潰解決方法
這篇文章主要介紹了jquery.uploadify插件在chrome瀏覽器頻繁崩潰解決方法,十分的實用,遇到相同問題,需要解決的朋友可以參考下2015-03-03jQuery實現(xiàn)自動調用和觸發(fā)某個事件的方法
這篇文章主要介紹了jQuery實現(xiàn)自動調用和觸發(fā)某個事件的方法,結合實例形式列舉分析了jQuery事件觸發(fā)的常見操作技巧,需要的朋友可以參考下2016-11-11