html組件不可輸入(只讀)同時(shí)任何組件都有效
更新時(shí)間:2013年04月01日 09:05:34 作者:
在開發(fā)過(guò)程中經(jīng)常會(huì)碰到讓html組件不可輸入(只讀),任何組件都有效的情況,接下來(lái)將為大家詳細(xì)實(shí)現(xiàn)下,感興趣的朋友可以參考下哈
復(fù)制代碼 代碼如下:
/**
* 將頁(yè)面設(shè)置為只讀
*/
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();" />';
});
});
}
相關(guān)文章
Jquery Ajax 學(xué)習(xí)實(shí)例2 向頁(yè)面發(fā)出請(qǐng)求 返回JSon格式數(shù)據(jù)
處理業(yè)務(wù)數(shù)據(jù),產(chǎn)生JSon數(shù)據(jù),供JqueryRequest.aspx調(diào)用2010-03-03jqueryMobile 動(dòng)態(tài)添加元素,展示刷新視圖的實(shí)現(xiàn)方法
下面小編就為大家?guī)?lái)一篇jqueryMobile 動(dòng)態(tài)添加元素,展示刷新視圖的實(shí)現(xiàn)方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-05-05jquery.uploadify插件在chrome瀏覽器頻繁崩潰解決方法
這篇文章主要介紹了jquery.uploadify插件在chrome瀏覽器頻繁崩潰解決方法,十分的實(shí)用,遇到相同問(wèn)題,需要解決的朋友可以參考下2015-03-03jQuery實(shí)現(xiàn)自動(dòng)調(diào)用和觸發(fā)某個(gè)事件的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)自動(dòng)調(diào)用和觸發(fā)某個(gè)事件的方法,結(jié)合實(shí)例形式列舉分析了jQuery事件觸發(fā)的常見(jiàn)操作技巧,需要的朋友可以參考下2016-11-11jquery中toggle函數(shù)交替使用問(wèn)題
jQuery 的toggle()函數(shù)使用show()或hide()函數(shù)來(lái)切換HTML元素的可見(jiàn)狀態(tài)。今天我們來(lái)探討下jquery中toggle函數(shù)交替使用問(wèn)題2015-06-06基于jQuery.Validate驗(yàn)證庫(kù)知識(shí)點(diǎn)的詳解
本篇文章介紹了,基于jQuery.Validate驗(yàn)證庫(kù)知識(shí)點(diǎn)的詳解。需要的朋友參考下2013-04-04