首頁 >web前端 >js教程 >html元件不可輸入(唯讀)同時任何元件都有效_jquery

html元件不可輸入(唯讀)同時任何元件都有效_jquery

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原創
2016-05-16 17:38:511256瀏覽
複製程式碼如下程式碼:

/**
* 將頁面設定為唯讀
*/
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