布丁足迹

千里始足下,高山起微尘,吾道亦如此,行之贵日新。

js表单禁用质恢及激活方法

想让表单显示又不想让修改.这方法挺适用.简单明了.一句disabled="disabled"就禁用了.还想打开就又得JS了.

下面是代码:IE6,7,8,FF都测试了.没什么题.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>js表单禁用质恢及激活方法-布丁足迹ddhbb.com</title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<script type="text/javascript">
    function $(id) {return document.getElementById(id)}
    function editInput(tag) {
        obj = $(tag);
        if(!obj) return false;
        obj.style.backgroundColor = "#c4c4c4";
        $('bt').onclick=function() {
            obj.disabled = false;
            obj.style.backgroundColor = "#fff";
        }
    }
</script>
</head>
<body onload="editInput('test')">
<input type="text" value="布丁足迹ddhbb.com" disabled="disabled" id="test">
<input id="bt" type="button" value="修改">
</body>
</html>
 

« 轻松实现li内不换行,及文字不断行。META标签用法与含义大全 »
  • quote 1.haphic
  • http://www.esloy.com
  • 嗯, 这个脚本的写法挺有创意的.
    表单中的 JS 对界面信息的阐释能力, 不是说明文字能达到的高度. 让人不得不用啊...
    我刚开始很反感 JS 特效的. 至到做表单时才学了些 JS 脚本以让用户直观的理解如何填写. 后来的 JQ 实而不华的效果和功能应用才真正转变了我对 JS 的看法.
  • 2009-6-17 15:58:06 回复该留言

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

宣传推广栏

评论之星★★★☆

宣传推广栏

完全随机文章

最新评论及回复

最近留言

网站收藏

  • hidden

网站收藏

抓虾 鲜果
有道 QQ邮箱
feedsky

Powered By Z-Blog 1.8 Walle Build 91204

[过度上网,有害健康]    感谢诚网科技提供空间
版权所有 ? 2007-2010 布丁足迹 辽ICP备08100443号