流易

日日行,不怕千万里;常常做,不怕千万事。(https://github.com/poazy)

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
/**
 * 将页面设置为只读
 */
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。

posted on 2013-03-31 23:47  流易  阅读(491)  评论(0编辑  收藏  举报